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.");