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

        }
 public SampleTask(StateObject s1, StateObject s2)
 {
     _s1 = s1;
     _s2 = s2;
 }