Factory.StartNew effectively delegates the work of ThreadPool .
Threadpool will automatically create the number of threads to respond to the request if the number of threads is less than or equal to the number of processors. Once it reaches the number of processors, threadpool will immediately stop creating new threads. This makes sense because creating more threads than the number of processors introduces the overhead of scheduling threads and returns nothing.
Instead, it will throttle the creation of threads. It waits 500 ms to check if any work is working and there are no threads to process the request. If there are pending jobs, he will introduce a new thread (only one). This process continues until you have enough work.
When the work queue traffic is cleared, threadpool will destroy the threads. And the above process continues.
In addition, there is a max limit on the number of threadpool threads that can run simultaneously. If you click this, threadpool will stop creating more threads and wait for the previous work items to complete so that it can reuse the existing thread.
This is not the end of the story, it is minimized! These are a few of the decisions made by ThreadPool.
Now I hope that it will be clear why you see what you see.
Sriram sakthivel
source share