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); });
标签:Console,CurrentThread,Thread,ManagedThreadId,c#,并发,WriteLine,parallel 来源: https://www.cnblogs.com/zhangzhiping35/p/11058684.html