Code example for AtomicInteger

Methods: get, getAndDecrement

0
   public String write(Date value) throws Exception {
      return borrow().write(value);
   } 
    
   private Task borrow() throws InterruptedException {       
      int size = count.get();
       
      if(size > 0) {
         int next = count.getAndDecrement();
          
         if(next > 0) {
            return new Task(format);
         } 
      } 
      return queue.take();
   } 
    
    
   private void release(Task task) {
      queue.offer(task);
   }