Exemple #1
0
 static void RaceConditions()
 {
     var state = new StateObject();
     for (int i = 0; i < 2; i++)
     {
         Task.Run(() => new SampleTask().RaceCondition(state));
     }
 }
Exemple #2
0
        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);
        }
Exemple #3
0
 public SampleTask(StateObject s1, StateObject s2)
 {
     this.s1 = s1;
     this.s2 = s2;
 }
Exemple #4
0
 public SampleTask(StateObject s1, StateObject s2)
 {
     this.s1 = s1;
     this.s2 = s2;
 }