A thread pool is a fixed set of reusable worker threads that pull tasks from a shared work queue. It avoids the cost of creating a thread per task and caps the number of concurrent threads.
Why use one
Creating and destroying threads is expensive (stack allocation, OS scheduling setup), and unbounded thread creation exhausts memory and causes context-switch thrashing. A pool amortizes creation cost and bounds concurrency.
tasks → [ work queue ] → worker 1
worker 2 (N fixed workers pull & run)
worker 3
Example
concurrent.futures ThreadPoolExecutor
ThreadPoolExecutor(max_workers=) pool:
futures = [pool.submit(handle, req) req requests]
