package atomic;

import java.util.concurrent.CountDownLatch;

public class AtomicExample04 {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch latch = new CountDownLatch(2);
        // 此时为1
        latch.countDown();
        System.out.println(latch.getCount());

        // 此时为0
        latch.countDown();
        System.out.println(latch.getCount());

        // 还是为0
        latch.countDown();
        System.out.println(latch.getCount());

        latch.await();

        System.out.println(latch.getCount());
    }
}
