Is Task.Factory.StartNew() guaranteed to create at least one new thread?

前端 未结 6 2015
一生所求
一生所求 2021-01-24 14:38

I understand that the TPL does not necessarily create a new thread for every task in a parallel set, but does it always create at least one? eg:

private void MyF         


        
6条回答
  •  情书的邮戳
    2021-01-24 15:27

    Yes, it will hit very shortly after dispatching the task to run.

    No, it will not create a new thread, but claim one. When they say it doesn't always create a new thread, they are referring to the fact that it re-uses threads from a thread pool.

    The size of the pool is based on the number of CPU cores detected. But it will always contain at least 1 thread. ;)

提交回复
热议问题