join源码
public final synchronized void join(long millis) throws InterruptedException {long base = System.currentTimeMillis();long now = 0;if (millis < 0) {throw new IllegalArgumentException("timeout value is negative");}if (millis == 0) {while (isAlive()) {wait(0);}} else {while (isAlive()) {long delay = millis - now;if (delay <= 0) {break;}wait(delay);now = System.currentTimeMillis() - base;}}}
t1.join() 等价于下面的代码
synchronized (t1) {// 调用者线程进入 t1 的 waitSet 等待, 直到 t1 运行结束while (t1.isAlive()) {t1.wait(0);}}
