コード例 #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
ファイル: Program.cs プロジェクト: mallickhruday/MyDemos
        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();
        }