using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Csh
{
class _11_多线程Parallel
{
private static void Adss(int x)
{
Console.WriteLine("{0}", x);
}
static void Main()
{
Parallel.For(0, 10, Adss);//很显然每次处理顺序不一样
}
}
}
复制粘贴代码,运行可以发现每次输出结果顺序不一致
比如12347586910,第二次可能是10839765421
,即可明白此方法的运行原理。