2
using System;
using System.Threading;
using System.Threading.Tasks;
class Program
{
static void Main()
{
double[] numbers = new double[10000];
Parallel.For(0, 9999, index => numbers[index] = index * 3);
Thread.MemoryBarrier();
// do something with numbers
}
}
MemoryBarrier()是上面所要求的,還是Parallel.For有內置的內存屏障?此代碼中是否需要MemoryBarrier?