This article describes the Thread Pool design pattern. This is a concurrency design pattern, a category of design pattern used by software engineers, when writing computer programs.

Table of Contents

Introduction

The Thread Pool pattern is a design pattern, used in software engineering to organise the processing of a large number of queued tasks through a smaller/limited number of threads. Results can also be queued. When a thread finishes it's task it requests another. If none are available, the thread can wait or terminate.

The size of the thread pool is a tuning parameter that allows fine tuning of resource usage and responsiveness, for best results. Pooling threads helps improve performance by saving time creating the thread, however, too many idle threads can consume resources. The number of threads is based on percentage used of CPU, queued requests, and/or the number of processors in the system.

This pattern is defined as a concurrency design pattern because it relates to thread management.

Return to Top


Benefits

Better performance is the main gain with this pattern. Juggling the various factors that determine performance becomes more important as computers leaverage multiple processor cores.

If the number of tasks is large, creating a thread for each may become impossible or impractical, so the best answer is a thread pool.

 

Return to Top


Examples of the pattern

A web server increases of decreases the number of request processing threads, depending on load.

 

Return to Top


See Also

Link to domain parent articles and related articles in TechNet Wiki.

 

Return to Top


Community Resources

These are the external links, including links to Microsoft and TechNet sites that are non-Wiki

 

Return to Top


References section

Use this section if you pulled source material and ideas from other sites, blogs, or forums. Make sure you have permission from authors to use their material.

 

 

Return to Top