加入等待直到线程死亡.如果你在一个死线程上调用它,它应该立即返回.这是一个演示:
public class Foo extends Thread {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("Start");
Foo foo = new Foo();
try {
// uncomment the following line to start the foo thread.
// foo.start();
foo.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Finish");
}
public void run() {
System.out.println("Foo.run()");
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3286 次 |
| 最近记录: |