BookRags.com Literature Guides Literature
Guides
Criticism & Essays Criticism &
Essays
Questions & Answers Questions &
Answers
Lesson Plans Lesson
Plans
My Bibliography Periodic Table U.S. Presidents Shakespeare Sonnet Shake-Up
Research Anything:        
History | Encyclopedias | Films | News | Create a Bibliography | More... Login | Register | Help
Not What You Meant?  There are 37 definitions for Pool.

Thread pool pattern

Print-Friendly
About 1 pages (377 words)

Bookmark and Share Know this topic well? Help others and get FREE products!

In the thread pool pattern in programming, a number of threads are created to perform a number of tasks, which are usually organized in a queue. Typically, there are many more tasks than threads. 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 is a parameter that can be tuned to provide the best performance. Additionally, the number of threads can be dynamic based on the number of waiting tasks. For example, a web server can add threads if numerous web page requests come in and can remove threads when those requests taper down. The cost of having a larger thread pool is increased resource usage. The algorithm that determines when creating or destroying threads will have an impact on the overall performance:

  • create too many threads and resources are wasted and time also wasted creating the unused threads
  • destroy too many threads and more time will be spent later creating them again
  • creating threads too slowly might result in poor client performance (long wait times)
  • destroying threads too slowly may starve other processes of resources

The algorithm chosen will depend on the problem and the expected usage patterns. 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

View More Summaries on Thread pool pattern
 
Ask any question on Thread pool pattern and get it answered FAST!
Answer questions in BookRags Q&A and earn points toward
discounted or even FREE Study Guides and other BookRags products!
Learn more about BookRags Q&A
Copyrights
Thread pool pattern from Wíkipedia. ©2006 by Wíkipedia. Licensed under the GNU Free Documentation License. View a list of authors or edit this article.

Article Navigation
Join BookRagslearn moreJoin BookRags




About BookRags | Customer Service | Report an Error | Terms of Use | Privacy Policy