Thread pool pattern
From Wikipedia, the free encyclopedia
In the thread pool pattern in programming, a number of N threads are created to perform a number of M tasks, usually organized in a queue. Typically, N << M. As soon as a thread completes its task, it will request the next task from the queue until all tasks have been completed. The thread can then terminate, or sleep until there are new tasks available.
The number of threads used (N) is a parameter that can be tuned to provide the best performance.
The advantage of using a Thread Pool over creating a new thread for each task, is that thread creation and destruction overhead is negated, which may result in better performance and better system stability.
When implementing this pattern, the programmer should ensure thread-safety of the queue.
[edit] See also
[edit] External links
- Article "Thread pools and work queues" by Brian Goetz
- Article "A Method of Worker Thread Pooling" by Pradeep Kumar Sahu
- Article "Work Queue" by Uri Twig
- Article "Windows Thread Pooling and Execution Chaining"
- Article "Smart Thread Pool" by Ami Bar
- Article "Programming the Thread Pool in the .NET Framework" by David Carmona
- Paper "Optimizing Thread-Pool Strategies for Real-Time CORBA" by Irfan Pyarali, Marina Spivak, Douglas C. Schmidt and Ron Cytron
- Business logic processing in a socket server - thread pools
java.util.concurrent.ThreadPoolExecutor
- The Thread Pool and Asynchronous Methods
- GThreadPool
- ZThreads PoolExecutor Class Reference
- Quasar Class ThreadPool
- Jason Class ThreadPool
- PoCo interface
- threadpool C++ threadpool library based on the boost library
- Package org.quickserver.util.pool.thread
- Tcl threading extension implementing pools of worker threads
- ACE_Thread_Manager Class Reference
- Thread::Pool Perl extension
- Citations from CiteSeer