Skip to content

Instantly share code, notes, and snippets.

@rajeevprasanna
Created April 12, 2014 08:54
Show Gist options
  • Save rajeevprasanna/10525547 to your computer and use it in GitHub Desktop.
Save rajeevprasanna/10525547 to your computer and use it in GitHub Desktop.
package example6;
public class ThreadJoinDemo implements Runnable {
public void run() {
Thread t = Thread.currentThread();
System.out.print(t.getName());
// checks if this thread is alive
System.out.println(", status = " + t.isAlive());
}
public static void main(String args[]) throws Exception {
Thread t = new Thread(new ThreadJoinDemo());
// this will call run() function
t.start();
// waits for this thread to die
//run again by commenting below join code
t.join();
System.out.print(t.getName());
// checks if this thread is alive
System.out.println(", status = " + t.isAlive());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment