# Threadpool The library for Linux C language to use Threadpool pattern. Design Patterns and Refactoring articles and guides. Thread pooling in C++11. Create a custom thread pool with required variables/constants set. The design patterns in most general OOP languages have developed to a vast majority of techniques. While designing a Thread Pool we should be careful while choosing the number of threads, because if number of Threads in a Thread Pool are more or less than required then it can hamper the process’s performance and stability. The Command Pattern and the Chain of Responsibility pattern lends itself elegantly for the implementation of the Thread Pool design. A thread pool is a technique that allows developers to exploit the concurrency of modern processors in an easy and efficient manner. Thread pool is a collection of threads which can be used to perform no of task in background. Provide a way for cancelling an already requested task. Simple descriptions and full source code examples in Java, C++, C#, PHP and Delphi. Thread Pooling in Csharp. While designing a Thread Pool we should be careful while choosing the number of threads, because if number of Threads in a Thread Pool are more or less than required then it can hamper the process’s performance and stability. Let’s not go deeper in that at this moment – instead we will create our own Custom-Thread-Pool with minimum set of things for our demo. I admit option 2 sounds like the best solution to me, but I am very green in all of this, so I might be a bit naive and missing some obvious flaw. Reading time: 5+ minutes. It's easy because you send "work" to the pool and somehow this work gets done without blocking the main thread. The Command Pattern and Chain of Responsibility for implementing ThreadPool. Expectation is - that it will not maintain more than the MIN limit if threads are not busy executing task. In this article I will speak for one of the most important concepts when designing a multi-threading application – the Thread Pool. Define public interface for the threadpool with which it can be used. Simply definition in here: By using this class design pattern, user can reuse some threads smoothly. The Command Pattern and the Chain of Responsibility pattern lends itself elegantly for the implementation of the Thread Pool design. All of this thread is used main loop by libevent, so if user add fd with event, create or add new event in thread. As the name implies, Thread Pool is a pool of threads that are available to do any work. And C have good function "File desctipror" to catch event. Why do we need it, when to use it, how to design it (in C++)? For C, it's not better to use thread only as commands, it's better to wait event to use something. Typically, we have more tasks than threads. Creating a thread per connection and then destroying the thread the connection closes. Ask Question Asked 6 years, 11 ... you have to design a system of inter-thread communication, both for the purpose of telling the thread that there's something to do, as well as for communicating the actual work data. We will walk through the internal complexity it will bring. Therefore, we should design a Thread Pool in such a way that number of threads in it should be configurable at run time based on current situation of Load.