FileDocCategorySizeDatePackage
JoinThread.javaAPI DocExample2157Tue May 01 16:43:38 BST 2001None

JoinThread

public class JoinThread extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

        JoinMe nrf = new JoinMe("first thread");
        JoinMe nrs = new JoinMe("second thread");
        JoinMe nrt = new JoinMe("third thread");
 
        //check see who is alive
        System.out.println("Thread one is alive:  " + nrf.rt.isAlive());
        System.out.println("Thread two is alive:  " + nrs.rt.isAlive());
        System.out.println("Thread three is alive:  " + nrt.rt.isAlive());
        
                 
                   
         try
            {
              // Instruct main thread to wait for other threads to finish
              nrf.rt.join();
              nrs.rt.join();
              nrt.rt.join();
                 
             }
         catch(InterruptedException e)
             {
               System.out.println("Main thread interrupted.");
             }
         System.out.println("Thread one is alive:  " + nrf.rt.isAlive());
         System.out.println("Thread two is alive:  " + nrs.rt.isAlive());
         System.out.println("Thread three is alive:  " + nrt.rt.isAlive());
         System.out.println("Main thread exiting.");