コード例 #1
0
 //construct a new thread.
 public MyThread(string name, PingPong pp)
 {
     thread         = new Thread(new ThreadStart(this.run));
     pingpongObject = pp;
     thread.Name    = name;
     thread.Start();
 }
コード例 #2
0
        public void TestMonitorWaitPulseExample()
        {
            PingPong pp = new PingPong();

            Console.WriteLine("The Ball is dropped... \n");
            MyThread mythread1 = new MyThread("Ping", pp);
            MyThread mythread2 = new MyThread("Pong", pp);

            mythread1.thread.Join();
            mythread2.thread.Join();
            Console.WriteLine("\nThe Ball Stops Bouncing.");
            Console.ReadLine();
        }