class CancellableCountDownLatch extends CountDownLatch {

    public void cancelWithException(RuntimeException ex) {
        if (getCount() == 0 || isCancelled) {
            return;
        }
        isCancelled = true;
        exception = ex;
        while (getCount() > 0) {
            countDown();
        }
    }

    public  CancellableCountDownLatch(int count);

}