public static void Interlock(int NumberIterations) { IntWrap addMe = new IntWrap(); for (int i = 0; i < NumberIterations; ++i) { System.Threading.Interlocked.Increment(ref addMe.data); } }
public static void Lock(int NumberIterations) { IntWrap addMe = new IntWrap(); for (int i = 0; i < NumberIterations; ++i) { lock (addMe){ ++addMe.data; } } }