static void RaceConditions() { var state = new StateObject(); for (int i = 0; i < 2; i++) { Task.Run(() => new SampleTask().RaceCondition(state)); } }
static void Deadlock() { var s1 = new StateObject(); var s2 = new StateObject(); Task.Run(() => new SampleTask(s1, s2).Deadlock1()); Task.Run(() => new SampleTask(s1, s2).Deadlock2()); Thread.Sleep(100000); }
public SampleTask(StateObject s1, StateObject s2) { this.s1 = s1; this.s2 = s2; }
public SampleTask(StateObject s1, StateObject s2) { this.s1 = s1; this.s2 = s2; }