public void i6() { DoParallel d = new DoParallel(); IStack <int> stack = new IntStackWrapper(new LockfreeStack <int>()); d.Add("t1", () => { stack.Push(1); }); d.Add("t2", () => { stack.Push(2); }); d.Add("t3", () => { int x = Chess.Choose(2) + 1; stack.Contains(x); }); d.Execute(); }
public static void Main() { Thread t1 = new Thread(delegate(object o) { int choice = Chess.Choose(5); }); Thread t2 = new Thread(delegate(object o) { int choice = Chess.Choose(5); }); CalculateTest c = new CalculateTest(); t1.Start(c); t2.Start(c); t1.Join(); t2.Join(); }
public static void Main() { x = 0; Thread t1 = new Thread(delegate(object o) { Interlocked.Increment(ref x); }); Thread t2 = new Thread(delegate(object o) { Interlocked.Increment(ref x); int choice = Chess.Choose(1); Interlocked.Increment(ref x); }); t1.Start(null); t2.Start(null); t1.Join(); t2.Join(); }
public static void Main() { Thread t1 = new Thread(delegate(object o) { Monitor.Enter(o); int choice = Chess.Choose(2); Monitor.Exit(o); }); Thread t2 = new Thread(delegate(object o) { Monitor.Enter(o); int choice = Chess.Choose(1); Monitor.Exit(o); }); CalculateTest c = new CalculateTest(); t1.Start(c); t2.Start(c); t1.Join(); t2.Join(); }
public static void Main() { int choice = Chess.Choose(6); }