Thread Pool

The thread pool is used to reduce such costs and even to avoid excessive context switching by multiplexing multiple units of work onto the same physical operating system thread that gets reused.

Thread Pool Work Item Queue Thread Pool Work Item Queue

Creation of new threads is a fairly expensive operation. Allocation of the thread’s stack and various data structures requires the scheduler database to be updated to gain knowledge about the thread’s existence. Typical use of the thread pool is to deal with relatively short-lived work items that need to execute in the background. Reuses physical operating system threads. The .NET thread pool multiplexes work items onto system threads.

Using the thread pool for long-running work used to be problematic because you were stealing away a worker in the thread pool for a long time. The engineering done to the task infrastructure (and the underlying revamped thread pool on top of which the TPL and tasks are built) means that tasks can now be used for long-running work, too.