Code example for Queue

Methods: offer

0
        // Avoid to create a new queue every time, just to be discarded immediately 
        Queue<ByteBuffer> byteBuffers = buffers.get(bucket);
        if (byteBuffers == null)
        { 
            byteBuffers = new ConcurrentLinkedQueue<>();
            Queue<ByteBuffer> existing = buffers.putIfAbsent(bucket, byteBuffers);
            if (existing != null)
                byteBuffers = existing;
        } 
 
        buffer.clear();
        byteBuffers.offer(buffer);
    } 
 
    public void clear() 
    { 
        directBuffers.clear();
        heapBuffers.clear();
    } 
 
Stop searching for code, let great code find you!  Add Codota to your java IDE