package 第三章.倒计时器CountDownLatch; import java.util.concurrent.CountDownLatch; /** * Created by zzq on 2018/1/24. */public class CountDoenLatchTest implements Runnable{static CountDownLatch countDownLatch=new CountDownLatch(3); public void run() { try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } countDownLatch.countDown(); } public static void main(String[] args) throws InterruptedException { CountDoenLatchTest countDoenLatchTest=new CountDoenLatchTest(); Thread thread=new Thread(countDoenLatchTest); Thread thread2=new Thread(countDoenLatchTest); Thread thread3=new Thread(countDoenLatchTest); thread.start();// thread2.start();// thread3.start(); countDownLatch.await(); System.out.println("主线程执行----------"); }}
原文地址:https://www.cnblogs.com/anxbb/p/8425544.html
时间: 2024-10-06 01:10:07