Anurag Agarwal b92eb5229d Resolves checkstyle errors for template-method thread-pool throttling tls tolerant-reader (#1073)
* Reduces checkstyle errors in template-method

* Reduces checkstyle errors in thread-pool

* Reduces checkstyle errors in throttling

* Reduces checkstyle errors in tls

* Reduces checkstyle errors in tolerant-reader
2019-11-10 19:45:17 +02:00
..
2017-11-28 20:55:52 +02:00
2019-10-12 20:05:54 +03:00
2017-11-28 21:28:53 +02:00

layout, title, folder, permalink, categories, tags
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