public class LinkedBlockingQueue extends AbstractQueue<E>
implements BlockingQueue<E> Serializable

An optionally-bounded {@linkplain BlockingQueue blocking queue} based on linked nodes. This queue orders elements FIFO (first-in-first-out). The head of the queue is that element that has been on the queue the longest time. The tail of the queue is that element that has been on the queue the shortest time. New elements are inserted at the tail of the queue, and the queue retrieval operations obtain elements at the head of the queue. Linked queues typically have higher throughput than array-based queues but less predictable performance in most concurrent applications.

The optional capacity bound constructor argument serves as a way to prevent excessive queue expansion. The capacity, if unspecified, is equal to MAX_VALUE. Linked nodes are dynamically created upon each insertion unless this would bring the queue above capacity.

This class and its iterator implement all of the optional methods of the Collection and Iterator interfaces.

Public Constructor Summary

Creates a LinkedBlockingQueue with a capacity of MAX_VALUE.
LinkedBlockingQueue(int capacity)
Creates a LinkedBlockingQueue with the given (fixed) capacity.
LinkedBlockingQueue(Collection<? extends E> c)
Creates a LinkedBlockingQueue with a capacity of MAX_VALUE, initially containing the elements of the given collection, added in traversal order of the collection's iterator.

Public Method Summary

Atomically removes all of the elements from this queue.
contains(Object o)
Returns true if this queue contains the specified element.
drainTo(Collection<? super E> c, int maxElements)
Removes at most the given number of available elements from this queue and adds them to the given collection.