@Test public void zeroCountDownTriggersCallback() { final AtomicInteger timesCalled = new AtomicInteger(0); final CallbackCountDownLatch latch = new CallbackCountDownLatch(2, timesCalled::getAndIncrement); assertThat(timesCalled).hasValue(0); latch.countDown(); assertThat(timesCalled).hasValue(0); latch.countDown(); assertThat(timesCalled).hasValue(1); latch.countDown(); assertThat(timesCalled).hasValue(1); }
@Override public void countDown() { super.countDown(); if (getCount() <= 0) { future.complete(null); } }
CallbackCountDownLatch extends CountDownLatch { @Override public void countDown() { super.countDown(); if (getCount() <= 0) { future.complete(null); } } }
CallbackCountDownLatch extends CountDownLatch { @Override public void countDown() { super.countDown(); if (getCount() <= 0) { future.complete(null); } } CallbackCountDownLatch(int size, Runnable callback);  CallbackCountDownLatch(int size, Runnable callback, Executor executor); }
CallbackCountDownLatch extends CountDownLatch { @Override public void countDown() { super.countDown(); if (getCount() <= 0) { future.complete(null); } } CallbackCountDownLatch(int size, Runnable callback);  CallbackCountDownLatch(int size, Runnable callback, Executor executor); @Override void countDown(); }
CallbackCountDownLatch extends CountDownLatch { @Override public void countDown() { super.countDown(); if (getCount() <= 0) { future.complete(null); } } CallbackCountDownLatch(int size, Runnable callback);  CallbackCountDownLatch(int size, Runnable callback, Executor executor); @Override void countDown();  }