CountDownLatch减法计数器
package com.king.add;
import java.util.concurrent.CountDownLatch;
//计数器
public class CountDownLatchDemo {
public static void main(String[] args) throws InterruptedException {
//总数是6
CountDownLatch countDownLatch = new CountDownLatch(6);
for (int i = 0; i < 6; i++) {
new Thread(()->{
System.out.println(Thread.currentThread().getName()+"Go out");
countDownLatch.countDown();
},String.valueOf(i)).start();
}
countDownLatch.await();
// countDownLatch.countDown();
System.out.println("Close Door");
}
}