예제 #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 static void Main()
        {
            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.Read();
        }