Thread pool pattern
From Free net 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.
See also
External links
- 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
- Template:Javadoc:SE
- The Thread Pool and Asynchronous Methods
- GThreadPool
- ZThreads PoolExecutor Class Reference
- Quasar Class ThreadPool
- Jason Class ThreadPool
- C++ threadpool library
- Portable Threads Library
- Package org.quickserver.util.pool.thread
- Tcl threading extension implementing pools of worker threads
- Thread::Pool Perl extension
- Citations from CiteSeer