int a = 0;
System.Threading.Tasks.Parallel.For(0, 100000, (i) =>
{
a++;
});
Console.Write(a);

解决方案如下

int a = 0;
object lockObj= new object();
System.Threading.Tasks.Parallel.For(0, 100000, (i) =>
{
lock (lockObj)
{
a++;
}
});
Console.Write(a);

结果就正常了.