Design patterns implementation examples

Thread Pool

Definition:

Pool of threads are used to execute number of tasks


Example:

We want to build server which process pending user requests. A thread pool offers a solution by reusing threads for multiple tasks, the thread creation overhead is spread over many tasks. Constant value of threads in pool prevent server from overloading.


C++ code:

/src/threadpool.cpp
Download source code