Code example for BlockingQueue

Methods: add, remainingCapacity

0
    } 
 
    public boolean put(LineProcessorMessage m) { 
        Boolean result = Boolean.TRUE; 
         
        if (bucket.remainingCapacity() > 0 ) { 
            bucket.add(m); 
        } 
        else { 
            bucket.clear(); 
            bucket.add(m); 
            result = Boolean.FALSE; 
        } 
        return result; 
    } 
    public LineProcessorMessage take() throws InterruptedException { 
        return bucket.take(); 
    } 
    public LineProcessorMessage take(long timeout,TimeUnit unit) throws InterruptedException { 
        return bucket.poll(timeout,unit); 
    }