What is the use of a Thread pool in Java?

A thread pool is a group of threads initially created that waits for jobs and executes them. The idea is to have the threads always existing, so that we won't have to pay overhead time for creating them every time. They are appropriate when we know there's a stream of jobs to process, even though there could be some time when there are no jobs.

Here's a nice diagram from Wikipedia: alt text


Thread Pools from the Java Tutorials has a good overview:

Using worker threads minimizes the overhead due to thread creation. Thread objects use a significant amount of memory, and in a large-scale application, allocating and deallocating many thread objects creates a significant memory management overhead.


A simple Google search will result in a wealth of information regarding Java thread pools and thread pools in general.

Here are some helpful links:

  • http://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html

  • http://en.wikipedia.org/wiki/Thread_pool_pattern