Code example for CountDownLatch

Methods: countDown, getCount

0
        if (isDone()) { 
            return false; 
        } else { 
            unRegister(); 
            canceled = true;
            this.latch.countDown();
            return !isDone(); 
        } 
    } 
 
    /* (non-Javadoc) 
     * @see java.util.concurrent.Future#isCancelled() 
     */ 
    @Override 
    public boolean isCancelled() { 
        return canceled;
    } 
 
    /* (non-Javadoc) 
     * @see java.util.concurrent.Future#isDone() 
     */ 
    @Override 
    public boolean isDone() { 
        return this.latch.getCount() == 0;
    } 
 
    /* (non-Javadoc) 
     * @see java.util.concurrent.Future#get() 
     */