Scalable Custom Thread Pool


Saurabh Chopra

In this blog, I would like to demonstrate how to create custom thread pool with scalability feature.

For scalability, we have to give a minimum number and a maximum number. Minimum number of threads would be continuously running in the thread pool. If we get multiple number of tasks to perform then thread pool will scale up to the maximum number that we have provided and once all the tasks are finished, it will scale down to the minimum number.   

We have to create our own queue which contains two methods i.e. enqueue and dequeue.

Enqueue is to add new task to the queue. 
Dequeue is to get the task from the queue and remove it.

Interface CustomQueue:
Implementation for CustomQueue interface will be MyQueue
 In MyQueue class you can see one method that is getQueueLength(). This method is used to get number of tasks that are lined up in…

View original post 292 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s