Beispiel #1
0
            public void DeadLock1()
            {
                int i = 0;

                while (true)
                {
                    lock (_s1)
                    {
                        lock (_s2)
                        {
                            _s1.ChangeState(i);
                            _s2.ChangeState(i++);
                            Console.WriteLine($"Still running {i}");
                        }
                    }
                }
            }
            public void RaceCondition(object o)
            {
                Trace.Assert(o is StateObject, "o must be a StateObkect");
                StateObject stateObject = o as StateObject;
                int         i           = 0;

                while (true)
                {
                    stateObject.ChangeState(i++);
                }
            }
Beispiel #3
0
            public void RaceCondition(object o)
            {
                Trace.Assert(o is StateObject, "o must be of type stateobject");
                StateObject state = o as StateObject;
                int         i     = 0;

                while (true)
                {
                    lock (state)
                    {
                        state.ChangeState(i++);
                    }
                }
            }