예제 #1
0
파일: Program.cs 프로젝트: ittray/LocalDemo
        static void Main(string[] args)
        {
            PrintNum printNum = new PrintNum();
            for (int i = 0; i < 3; i++)
            {
                Thread temp = new Thread(new ThreadStart(printNum.PrintOddNum));
                temp.Start();
            }

            lock (printNum)
            {
                Console.WriteLine("Main thread will delay 5 seconds");

                Thread.Sleep(5000);
                Console.WriteLine("Main thread already delayed 5 seconds, Press any key to exit.");
            }

            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            PrintNum printNum = new PrintNum();

            for (int i = 0; i < 3; i++)
            {
                Thread temp = new Thread(new ThreadStart(printNum.PrintOddNum));
                temp.Start();
            }

            lock (printNum)
            {
                Console.WriteLine("Main thread will delay 5 seconds");

                Thread.Sleep(5000);
                Console.WriteLine("Main thread already delayed 5 seconds, Press any key to exit.");
            }

            Console.ReadLine();
        }