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

后端 未结 3 1768
执笔经年
执笔经年 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:02

    By default, the MaxThreads of the ThreadPool is very high. Usually you'll never get there, your app will crash first.

    So when all threads are busy the new tasks are queued and slowly, at most 1 per 500 ms, the TP will allocate new threads.

提交回复
热议问题