Code example for BlockingQueue

Methods: offer

0
        int count = size.incrementAndGet();
        if (count > capacity) {
            size.decrementAndGet();
            return false; 
        } 
        boolean offered = queue.offer(e);
        if (!offered) {
            size.decrementAndGet();
        } 
        return offered;
    } 
 
    @Override 
    public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException {
        // note, not used in ThreadPoolExecutor 
        throw new ElasticSearchIllegalStateException("offer with timeout not allowed on size queue"); 
    } 
 
    @Override 
    public void put(E e) throws InterruptedException {