CyclicBarrier和CountDownLatch一样,都是关于线程的计数器. 用法略有不同,测试代码如下: 1 public class TestCyclicBarrier { 2 3 private static final int THREAD_NUM = 5; 4 5 public static class WorkerThread implements Runnable{ 6 7 CyclicBarrier barrier; 8 9 public WorkerThread(Cyc…
javadoc里面的描述是这样的. CountDownLatch: A synchronization aid that allows one or more threads to wait until a set of operations being performed in other threads completes. CyclicBarrier : A synchronization aid that allows a set of threads to all wait for e…