t.join();表示当前线程停止执行直到t线程运行完毕;
t.join(1000); 表示当前线程等待t线程运行1000后执行;
/*
* Test.java
*
* Created on 2008年2月25日, 上午9:57
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
/**
*
* @author rulinma
*/
public class Test {
/** Creates a new instance of Test */
public Test() {
}
//Display a message, preceded by the name of the current thread
static void threadMessage(String message) {
本文通过实例代码解析了Java中的Thread.join方法,包括无参数版本和指定等待时间版本的使用,展示了如何控制线程同步,确保主线程等待子线程执行完毕或达到指定时间后再继续执行。
订阅专栏 解锁全文
217

被折叠的 条评论
为什么被折叠?



