Maximum queued elements in ThreadPool.QueueUserWorkItem

后端 未结 4 1740
醉梦人生
醉梦人生 2020-12-31 18:19

I set the max thread to 10. Then I added 22000 task using ThreadPool.QueueUserWorkItem. It is very likely that not all the 22000 task was completed after running the program

4条回答
  •  长情又很酷
    2020-12-31 19:14

    This is an implementation dependent question and the implementation of this function has changed a bit over time. But in .Net 4.0, you're essentially limited by the amount of memory in the system as the tasks are stored in an in memory queue. You can see this by digging through the implementation in reflector.

提交回复
热议问题