What is the use of a Thread pool in Java?

JavaUser picture JavaUser · Jul 20, 2010 · Viewed 25.2k times · Source

What is the use of a Thread pool? Is there a good real world example?

Answer

Amir Rachum picture Amir Rachum · Jul 20, 2010

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