Created
April 12, 2014 08:54
-
-
Save rajeevprasanna/10525547 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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