C#相关的线程

for(int i =0;i<=5;i++)
{
    Thread th = new Thread(Dotaskfunction());
    th.Start();  
}
for(int i=0;i<=5;i++)
{
   Task.Run(()=>{Dotaskfunction();});
}

Task是C#线程的一种,与thread的不同在于,task执行任务时会从线程池中获取空闲的线程。

猜你喜欢

转载自www.cnblogs.com/mathyk/p/9465336.html