示例#1
0
        private static void GoodAsync()
        {
            Console.WriteLine("Синхронизация Блокировкой:");
            MonitorLockCounter c = new MonitorLockCounter();

            Thread[] threads = new Thread[5];
            for (int i = 0; i < threads.Length; ++i)
            {
                threads[i] = new Thread(c.UpdateFields);
                threads[i].Start();
            }

            for (int i = 0; i < threads.Length; ++i)
                threads[i].Join();

            Console.WriteLine("Field1: {0}, Field2: {1}\n\n", c.Field1, c.Field2);
        }
示例#2
0
        private static void GoodAsync()
        {
            Console.WriteLine("Синхронизация Блокировкой:");
            MonitorLockCounter c = new MonitorLockCounter();

            Thread[] threads = new Thread[5];
            for (int i = 0; i < threads.Length; ++i)
            {
                threads[i] = new Thread(c.UpdateFields);
                threads[i].Start();
            }

            for (int i = 0; i < threads.Length; ++i)
            {
                threads[i].Join();
            }

            Console.WriteLine("Field1: {0}, Field2: {1}\n\n", c.Field1, c.Field2);
        }