Chapter 21

Thread Pools

For performance reasons, threads are often pooled. Pooling helps reduce thread creation by reusing threads and makes it easier to place a bound on the number of active threads. A thread pool consists of generic workers that collectively execute the tasks submitted to the pool. Different types of thread pools exist, characterized by various properties: fixed or flexible number of workers, bounded or unbounded queue of tasks, scheduling and delaying facilities, and so on. Applications can use thread pools explicitly by submitting tasks directly to workers. Additionally, some languages define structures that can process their contents in parallel by submitting internal tasks to a thread pool. In functional and hybrid languages, ...

Get Functional and Concurrent Programming: Core Concepts and Features now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.