Exemplo n.º 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();
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            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.");



            Nonatomic_Erro();
            Atomic_Monitor();

            Console.Read();
        }