package yi.test01;
/**
* 2016年9月13日10:47:09
* @author yangwl
*
* join方法:
* join方法时让某个线程等待调用了join方法的线程结束后再继续执行
*/
public class Test02 {
public static void main(String[] args) throws InterruptedException {
System.out.println("Main Start.");
Thread t = new Thread(new Runnable() {
public void run() {
System.out.println("子线程 Start.");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("子线程 End.");
}
});
t.start();
t.join();
System.out.println("Main End.");
}
}
Main Start.
Main End.
子线程 Start.
子线程 End.
Main Start.
子线程 Start.
子线程 End.
Main End.
java join的使用
最新推荐文章于 2023-12-04 12:12:30 发布