Code example for BlockingQueue

Methods: offer, put, size

0
    public boolean requestIncoming(Request request, long timeout) {
        boolean retval = true;
        if (matchesRequest(request)) {
            try { 
                if(timeout > 0) {
                    retval = queue.offer(request, timeout, TimeUnit.MILLISECONDS);
                } else { 
                    queue.put(request);
                } 
            } catch (InterruptedException e) {
                LOGGER.log(Level.WARNING,
                        "Unexpected interruption while blocking on the request queue"); 
            } 
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.fine(this + " queue size " + queue.size());
            } 
 
        } 
        return retval;
    }