这是因为你在同一时间从多个线程编写相同的字段.
使用System.Threading中的Interlocked.Add,这将阻止每个线程在同一时刻写入变量.
int sum = 0; Task t1 = Task.Factory.StartNew(() => { Interlocked.Add(ref sum,Computation()); }); Task t2 = Task.Factory.StartNew(() => { Interlocked.Add(ref sum,Computation()); }); Task t3 = Task.Factory.StartNew(() => { Interlocked.Add(ref sum,Computation()); }); Task.WaitAll(t1, t2, t3); Console.WriteLine($"The sum is {sum}");