Skip to content

Files

Latest commit

1c0e0cd · Mar 31, 2018

History

History

thread-pool

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Nov 28, 2017
Feb 19, 2018
Nov 28, 2017
Mar 31, 2018
layout title folder permalink categories tags
pattern
Thread Pool
thread-pool
/patterns/thread-pool/
Concurrency
Java
Difficulty-Intermediate
Performance

Intent

It is often the case that tasks to be executed are short-lived and the number of tasks is large. Creating a new thread for each task would make the system spend more time creating and destroying the threads than executing the actual tasks. Thread Pool solves this problem by reusing existing threads and eliminating the latency of creating new threads.

alt text

Applicability

Use the Thread Pool pattern when

  • you have a large number of short-lived tasks to be executed in parallel