@Test public void asyncCallback() { final Executor mockExecutor = mock(Executor.class); final Runnable noop = () -> { }; final CallbackCountDownLatch latch = new CallbackCountDownLatch(2, noop, mockExecutor); verify(mockExecutor, never()).execute(any()); latch.countDown(); verify(mockExecutor, never()).execute(any()); latch.countDown(); verify(mockExecutor).execute(any()); latch.countDown(); verify(mockExecutor).execute(any()); }
@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();  }