A thread pool ensures threads are used efficiently within the container. A number of threads are created at initialization and placed in the pool. When there is work to be done, for example to service a request, a free thread from the pool is allocated and then returned to the pool when the work has been completed.
Bounded Thread Pool
The thread pool implementation availabile in Jetty is called org.mortbay.thread.BoundedThreadPool. It is called "Bounded" because it manages the size of the thread pool based on configurable minimum and maximum numbers of threads.
If there are no free threads when one is required, a new thread will be created and placed in the pool if the maximum pool size has not been reached. If the maximum pool size is reached, jobs wait for a free thread. Idle threads in the pool will timeout and terminate until the minimum number of threads are running.
It is configured like so:
<Set name="ThreadPool"> <New class="org.mortbay.thread.BoundedThreadPool"> <Set name="minThreads">10</Set> <Set name="maxThreads">100</Set> </New> </Set>
- minThreads is the minimum number of threads allowed in the pool
- maxThreads is the maximum number of threads allowed in the pool
Change the minimum and maximum threads in accordance with the load profile of your installation.