7 Thread Pools
UNITS OF CONCURRENT work are often comparatively small, mostly independent, and often execute for a short period of time before producing results and going away. Creating a dedicated thread for each piece of work like this is a bad idea: there are sizeable runtime costs (both in time and space) paid for each thread that is created and destroyed. If we were to create a new thread for each task the system had to run, the cost of the actual computation itself would be dwarfed in no time. These impacts also include more time spent in the scheduler doing context switches once the number of threads exceeds the processor count, an impact to cache locality due to threads constantly having to move from one processor to another, and an ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access