Why so much difference in performance between Thread and Task?

后端 未结 6 1420
独厮守ぢ
独厮守ぢ 2020-12-14 16:36

Windows 7, Intel CORE i3, 64 bit, RAM 4Gb, 2.27 GHz
.NET Framework 4.0

I have the following code:

static void Main(string[] args)
{
             


        
6条回答
  •  一个人的身影
    2020-12-14 16:37

    Calling Task.Factory.StartNew doesn't necessarily create a new thread, they are managed by the TaskScheduler based upon how many cores etc the machine has that is running the code.

    If you schedule (by calling Task.Factory.StartNew) more tasks than can be concurrently run, they will be queued and run as more resources become available.

提交回复
热议问题