2 using System.Threading;
4 public class InterlockTest
12 public static int Main() {
15 InterlockTest it = new InterlockTest ();
18 int c = Interlocked.Exchange (ref it.test, 1);
26 b = Interlocked.Increment (ref a);
33 b = Interlocked.Decrement (ref a);
39 string s = IncTest ();
47 Console.WriteLine ("done!");
52 public static string IncTest () {
53 return "A" + Interlocked.Increment (ref s_test);