c# parallel.for怎么控制并发数量,控制多5个并发量

             Parallel.For(0,10,
                         new ParallelOptions(){MaxDegreeOfParallelism = 5},
                         (i, loopState) =>
                         {
                             System.Diagnostics.Debug.WriteLine("Start Thread={0}, i={1}", Thread.CurrentThread.ManagedThreadId, i);
 
                             Thread.Sleep(i*200);
                             Console.WriteLine("Finish Thread={0}, i={1}", Thread.CurrentThread.ManagedThreadId, i);
                         });

 

上一篇:C# 多线程


下一篇:【Proteus仿真】Arduino UNO驱动直流有刷电机启停实验