1.JAVA多线程(四)Java多线程之join等待结束
1.1 join(等待结束)
join()方法的作用,是等待这个线程结束;
也就是说,thread.join()方法阻塞调用此方法的线程(calling thread)进入 TIMED_WAITING 状态,直到线程thread完成,此线程再继续;
通常用于在main()主线程内,等待其它线程完成再结束main()主线程。
package com.yuanxw.chapter4;
public class ThreadJoin {
public static void main(String[] args) throws InterruptedException {
long startTime = System.currentTimeMillis();
Thread thread1 = new Thread(new SyncDatabase("T1","192.168.185.26",