When using Task what happens if the ThreadPool is full/busy?

后端 未结 3 1756
执笔经年
执笔经年 2020-12-31 23:50

When I am using the .Net 4 Task class which uses the ThreadPool, what happens if all Threads are busy?

Does the TaskScheduler create a new thread and extend the Thr

3条回答
  •  北海茫月
    2021-01-01 00:15

    It won't increase MaxThreads. When there are more tasks than available worker threads, some tasks will be queued and wait until the thread pool provides an available thread. It does some pretty advanced stuff to scale with a large number of cores (work-stealing, thread injection, etc).

提交回复
热议问题