Coordinating Threads with join : Thread Join « Thread « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Thread » Thread Join 
7.5.1.Coordinating Threads with join
The Thread that calls the join method of another Thread waits for the other Thread to die before proceeding. 


public class MainClass implements Runnable {
  public static void main(String[] args) {
    MainClass jt = new MainClass();
    try {
      jt.t.join();
      System.out.println("after join");
    catch (InterruptedException ex) {
      System.out.println("main exception:" + ex);
    }
  }

  Thread t;

  public MainClass() {
    t = new Thread(this);
    t.setPriority(Thread.MIN_PRIORITY);
    t.start();

  }

  public void run() {
    ;
  }
}
after join
7.5.Thread Join
7.5.1.Coordinating Threads with join
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.