Interview Question

What is a thread pool?

A thread pool executes many tasks using a controlled set of reusable workers.

💡 Concept ✅ Quick Revision ☕ Java

Answer

A thread pool reuses a managed set of worker threads to execute submitted tasks. • ExecutorService separates task submission from thread creation. • Pool and queue sizes affect throughput, latency, and resource use. • The executor should be shut down when it is no longer needed.

Example

Code
var executor = java.util.concurrent.Executors.newFixedThreadPool(2);
executor.submit(() -> System.out.println("task"));
executor.shutdown();
Output
task

Quick Revision

A thread pool executes many tasks using a controlled set of reusable workers.