@Test public void cancelWithException() { final RuntimeException ex = new RuntimeException("some exception"); assertThat(countDownLatch.getCount()).isEqualTo(10); assertThat(countDownLatch.getException()).isEqualTo(null); assertThat(countDownLatch.isCancelled()).isEqualTo(false); countDownLatch.cancelWithException(ex); assertThat(countDownLatch.getCount()).isEqualTo(0); assertThat(countDownLatch.getException()).isEqualTo(ex); assertThat(countDownLatch.isCancelled()).isEqualTo(true); }
public void cancelWithException(RuntimeException ex) { if (getCount() == 0 || isCancelled) { return; } isCancelled = true; exception = ex; while (getCount() > 0) { countDown(); } }
CancellableCountDownLatch extends CountDownLatch { public void cancelWithException(RuntimeException ex) { if (getCount() == 0 || isCancelled) { return; } isCancelled = true; exception = ex; while (getCount() > 0) { countDown(); } } }
CancellableCountDownLatch extends CountDownLatch { public void cancelWithException(RuntimeException ex) { if (getCount() == 0 || isCancelled) { return; } isCancelled = true; exception = ex; while (getCount() > 0) { countDown(); } } CancellableCountDownLatch(int count); }
CancellableCountDownLatch extends CountDownLatch { public void cancelWithException(RuntimeException ex) { if (getCount() == 0 || isCancelled) { return; } isCancelled = true; exception = ex; while (getCount() > 0) { countDown(); } } CancellableCountDownLatch(int count); void cancelWithException(RuntimeException ex); @Override void await(); @Override boolean await(long timeout, TimeUnit unit); }
CancellableCountDownLatch extends CountDownLatch { public void cancelWithException(RuntimeException ex) { if (getCount() == 0 || isCancelled) { return; } isCancelled = true; exception = ex; while (getCount() > 0) { countDown(); } } CancellableCountDownLatch(int count); void cancelWithException(RuntimeException ex); @Override void await(); @Override boolean await(long timeout, TimeUnit unit);  }