コード例 #1
0
 public static void RaceConditions()
 {
     var state = new StateObject();
     for (int i = 0; i < 2; i++)
     {
         Task.Run(() => new SampleTask().RaceCondition(state));
     }
 }
コード例 #2
0
        public 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());

            Task.Delay(10000).Wait();

        }
コード例 #3
0
 public SampleTask(StateObject s1, StateObject s2)
 {
     _s1 = s1;
     _s2 = s2;
 }