Creates a {@code LinkedBlockingQueue} with a capacity of {@link Integer#MAX_VALUE}.
Creates a {@code LinkedBlockingQueue} with the given (fixed) capacity.
Creates a {@code LinkedBlockingQueue} with a capacity of {@link Integer#MAX_VALUE}, initially containing the elements of the given collection, added in traversal order of the collection's iterator.
Linked list node class.
Atomically removes all of the elements from this queue. The queue will be empty after this call returns.
Returns {@code true} if this queue contains the specified element. More formally, returns {@code true} if and only if this queue contains at least one element {@code e} such that {@code o.equals(e)}.
@throws UnsupportedOperationException {@inheritDoc} @throws ClassCastException {@inheritDoc} @throws NullPointerException {@inheritDoc} @throws IllegalArgumentException {@inheritDoc}
@throws UnsupportedOperationException {@inheritDoc} @throws ClassCastException {@inheritDoc} @throws NullPointerException {@inheritDoc} @throws IllegalArgumentException {@inheritDoc}
Returns the predecessor of live node p, given a node that was once a live ancestor of p (or head); allows unlinking of p.
Locks to prevent both puts and takes.
Unlocks to allow both puts and takes.
Inserts the specified element at the tail of this queue, waiting if necessary up to the specified wait time for space to become available.
Inserts the specified element at the tail of this queue if it is possible to do so immediately without exceeding the queue's capacity, returning {@code true} upon success and {@code false} if this queue is full. When using a capacity-restricted queue, this method is generally preferable to method {@link BlockingQueue#add add}, which can fail to insert an element only by throwing an exception.
Inserts the specified element at the tail of this queue, waiting if necessary for space to become available.
Returns the number of additional elements that this queue can ideally (in the absence of memory or resource constraints) accept without blocking. This is always equal to the initial capacity of this queue less the current {@code size} of this queue.
Removes a single instance of the specified element from this queue, if it is present. More formally, removes an element {@code e} such that {@code o.equals(e)}, if this queue contains one or more such elements. Returns {@code true} if this queue contained the specified element (or equivalently, if this queue changed as a result of the call).
@throws NullPointerException {@inheritDoc}
@throws NullPointerException {@inheritDoc}
@throws NullPointerException {@inheritDoc}
Returns the number of elements in this queue.
Used for any element traversal that is not entirely under lock. Such traversals must handle both: - dequeued nodes (p.next == p) - (possibly multiple) interior removed nodes (p.item is null)
Returns an array containing all of the elements in this queue, in proper sequence.
Returns an array containing all of the elements in this queue, in proper sequence; the runtime type of the returned array is that of the specified array. If the queue fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this queue.
An optionally-bounded {@linkplain BlockingQueue blocking queue} based on linked nodes. This queue orders elements FIFO (first-in-first-out). The <em>head</em> of the queue is that element that has been on the queue the longest time. The <em>tail</em> 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.
<p>The optional capacity bound constructor argument serves as a way to prevent excessive queue expansion. The capacity, if unspecified, is equal to {@link Integer#MAX_VALUE}. Linked nodes are dynamically created upon each insertion unless this would bring the queue above capacity.
<p>This class and its iterator implement all of the <em>optional</em> methods of the {@link Collection} and {@link Iterator} interfaces.
<p>This class is a member of the <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework"> Java Collections Framework</a>.
@author Doug Lea @param (E) the type of elements held in this queue