Directory

Encyclopedia

NodeWorks
                              ENCYCLOPEDIA

Link Checker

Home
Encyclopedia : T : TH : THR :

Thread pool pattern

 

Thread pool pattern

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 << (is much smaller than) 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 will result in better performance, and better system stability.

When implementing this pattern, the programmer should ensure thread-safety of the queue.


NodeWorks boosts web surfing!
Page Returned in 0.064 seconds - HTML Compressed 68.8%

This article is from Wikipedia. All text is available
under the terms of the GNU Free Documentation License.
 GNU Free Documentation License
© 2008 Chamas Enterprises Inc.