Пример #1
0
        public void TestMonitorLock()
        {
            IRigidLocker locker  = new Never.Threading.MonitorLocker();
            var          threads = new System.Threading.Thread[2];

            threads[0] = new System.Threading.Thread(() =>
            {
                locker.EnterLock(false, () =>
                {
                    Console.WriteLine("first");
                    System.Threading.Thread.Sleep(2000);
                    Console.WriteLine("firstdone");
                });
            });

            threads[0].Start();

            threads[1] = new System.Threading.Thread(() =>
            {
                locker.EnterLock(false, () =>
                {
                    Console.WriteLine("two");
                });
            });

            threads[1].Start();
        }