2 using System.Threading;
4 public class InterlockTest
9 public static int Main() {
13 InterlockTest it = new InterlockTest ();
17 int c = Interlocked.Add (ref it.test, 1);
25 b = Interlocked.Add (ref a, 1);
33 int lc = Interlocked.Add (ref it.ltest, 1);
41 lb = Interlocked.Add (ref la, 1);
48 InterlockTest o1 = new InterlockTest ();
49 InterlockTest o2 = new InterlockTest ();
52 InterlockTest o3 = Interlocked.CompareExchange (ref o, o2, o2);
58 InterlockTest o4 = Interlocked.CompareExchange (ref o, o2, o1);
64 Console.WriteLine ("done!");