Code example for LinkedBlockingQueue

Methods: add

0
        this.timeout = timeout;
        this.options = options;
    } 
     
    public synchronized void add(String key) {
        queue.add( key );
    } 
     
    public int getTimeout() { 
        return timeout;
    } 
     
    //this is the blocking code  
    public synchronized String getNextMessage(int timeout) throws InterruptedException {
        return queue.poll( timeout, TimeUnit.SECONDS );
    } 
 
    public synchronized String getNextMessage() {
        return queue.poll();
    } 
Contextual code suggestions in your IDE  Get Codota for Java