Already on ArticleSlash?

Forgot your password? Sign Up

What is Thread Pooling & Why is it needed?


Visitors: 182

Thread pooling is the process of creating a collection of threads during the initialization of a multithreaded application, and then reusing those threads for new tasks as and when required, instead of creating new threads. The number of threads for the process is usually fixed depending on the amount of memory available, and the needs of the application. However, it might be possible to increase the number of available threads. Each thread in the pool is given a task and, once that task has completed, the thread returns to the pool and waits for the next assignment.

The Concept of Thread Pooling

One of the major problems affecting the responsiveness of a multithreaded application is the time involved in spawning threads for each task.

For example, a web server is a multithreaded application that can service several client requests simultaneously. Let’s suppose that ten clients are accessing the web server at the same time:

- If the server operates a one thread per client policy, it will spawn ten new threads to service these clients, which entails the overhead of first creating those threads and then of managing them throughout their lifetime. It’s also possible that the machine will run out of resources at some point.

- Alternatively, if the server uses a pool of threads to satisfy those requests, then it will save the time involved in the spawning of those threads each time a request from a client comes in. It can manage the number of threads created, and can reject client requests if it is too busy to handle them. This is exactly the concept behind thread pooling.

The factors affecting the threading design of a multithreaded application are:

- The responsiveness of the application
- The allocation of thread management resources
- Resource sharing
- Thread synchronization

Thread pooling is essential in multithreaded applications for the following reasons.

- Thread pooling improves the response time of an application as threads are already available in the thread pool waiting for their next assignment and do not need to be created from scratch
- Thread pooling optimizes the thread time slices according to the current process running in the system
- Thread pooling enables us to start several tasks without having to set the properties for each thread
- Thread pooling enables us to pass state information as an object to the procedure arguments of the task that is being executed
- Thread pooling can be employed to fix the maximum number of threads for processing a particular request.

Spec India is a Custom Software Application Development and Software Solutions Company based in Ahmedabad, India. Our Services includes iPhone Application Development , Android Application Development , ORACLE, . Net, and Mobile Computing.


Article Source:

Rate this Article: 
Energy is the Common Thread
Rated 4 / 5
based on 5 votes

Related Articles:

Dot Net - Connection Pooling

by: Adam Sturo (August 29, 2007) 
(Business/Careers Employment)

Tips For Car Pooling Savings

by: Janelle Elizabeth (July 30, 2008) 

Car pooling - A GREEN CHOICE

by: Mukesh Gaur (September 17, 2010) 
(Travel and Leisure)

Practical Car Pooling Tips for Neighbors

by: Levi Quinn (March 29, 2008) 

Key REMIC Provisions in Pooling and Servicing Agreements

by: Mark Warner (September 04, 2008) 

Payday Loans UK - Pooling Funds Between Your Paydays

by: Percy Peter (April 28, 2008) 
(Finance/PayDay Loans)

Why Not Thread Everything?

by: Venkatesh Pai (July 15, 2011) 
(Computers and Technology/Software)

How To Thread At Home?

by: Vidula Chopra (April 15, 2007) 
(Health and Fitness)

E-learning as a thread

by: Sundar Rawat (March 05, 2012) 
(Reference and Education/Online Education)

Energy is the Common Thread

by: Lawrence Losoncy (August 18, 2008)