@@ -0,0 +1,1463 @@
+// Using join() to wait for threads to finish.%0Aclass NewThread implements Runnable %7B%0A String name; // name of thread%0A Thread t;%0A NewThread(String threadname) %7B%0A name = threadname;%0A t = new Thread(this, name);%0A System.out.println(%22New thread: %22 + t);%0A t.start(); // Start the thread%0A %7D%0A // This is the entry point for thread.%0A public void run() %7B%0A try %7B%0A for(int i = 5; i %3E 0; i--) %7B%0A System.out.println(name + %22: %22 + i);%0A Thread.sleep(1000);%0A %7D%0A %7D catch (InterruptedException e) %7B%0A System.out.println(name + %22 interrupted.%22);%0A %7D%0A System.out.println(name + %22 exiting.%22);%0A %7D%0A%7D%0Aclass DemoJoinAlive %7B%0A public static void main(String args%5B%5D) %7B%0A NewThread ob1 = new NewThread(%22One%22);%0A NewThread ob2 = new NewThread(%22Two%22);%0A NewThread ob3 = new NewThread(%22Three%22);%0A //Note the Calling of Alive method%0A System.out.println(%22Thread One is alive: %22%0A + ob1.t.isAlive());%0A System.out.println(%22Thread Two is alive: %22%0A + ob2.t.isAlive());%0A System.out.println(%22Thread Three is alive: %22%0A + ob3.t.isAlive());%0A // wait for threads to finish%0A try %7B%0A System.out.println(%22Waiting for threads to finish.%22);%0A ob1.t.join();%0A ob2.t.join();%0A ob3.t.join();%0A %7D catch (InterruptedException e) %7B%0A System.out.println(%22Main thread Interrupted%22);%0A %7D%0A System.out.println(%22Thread One is alive: %22%0A + ob1.t.isAlive());%0A System.out.println(%22Thread Two is alive: %22%0A + ob2.t.isAlive());%0A System.out.println(%22Thread Three is alive: %22%0A + ob3.t.isAlive());%0A System.out.println(%22Main thread exiting.%22);%0A %7D%0A%7D%0A

Create DemoJoinAlive.java