Code example for CountDownLatch

Methods: countDown, getCount

0
     
    private volatile V v;
     
    public boolean set(V v){
         
        long count = latch.getCount();
      
        latch.countDown();
         
        if (count == latch.getCount()){
             
            return false; 
             
        } else { 
             
            this.v = v;
             
            return true; 
             
        }