public interface Pollable<E>
BlockingQueue interface| Modifier and Type | Method and Description |
|---|---|
int |
drainTo(java.util.Collection<? super E> c)
Removes all available elements from this queue and adds them to the given collection.
|
int |
drainTo(java.util.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.
|
E |
element()
Retrieves, but does not remove, the head of this queue.
|
E |
peek()
Retrieves, but does not remove, the head of this queue, or returns
null if this queue is empty. |
E |
poll()
Retrieves and removes the head of this queue, or returns
null if this queue is empty. |
E |
poll(long timeout,
java.util.concurrent.TimeUnit unit)
Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an element
to become available.
|
E |
remove()
Retrieves and removes the head of this queue.
|
E |
take()
Retrieves and removes the head of this queue, waiting if necessary until an element becomes available.
|
E remove()
poll only in that it throws
an exception if this queue is empty.java.util.NoSuchElementException - if this queue is emptyE poll()
null if this queue is empty.null if this queue is emptyE element()
peek only in that
it throws an exception if this queue is empty.java.util.NoSuchElementException - if this queue is emptyE peek()
null if this queue is empty.null if this queue is emptyE take() throws java.lang.InterruptedException
java.lang.InterruptedException - if interrupted while waitingE poll(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
timeout - how long to wait before giving up, in units of unitunit - a TimeUnit determining how to interpret the timeout parameternull if the specified waiting time elapses before an element is
availablejava.lang.InterruptedException - if interrupted while waitingint drainTo(java.util.Collection<? super E> c)
c may result in elements being in neither, either or both collections when the associated
exception is thrown. Attempts to drain a queue to itself result in IllegalArgumentException. Further, the
behavior of this operation is undefined if the specified collection is modified while the operation is in
progress.c - the collection to transfer elements intojava.lang.UnsupportedOperationException - if addition of elements is not supported by the specified collectionjava.lang.ClassCastException - if the class of an element of this queue prevents it from being added to the specified collectionjava.lang.NullPointerException - if the specified collection is nulljava.lang.IllegalArgumentException - if the specified collection is this queue, or some property of an element of this queue prevents it
from being added to the specified collectionint drainTo(java.util.Collection<? super E> c, int maxElements)
c may result in elements being in
neither, either or both collections when the associated exception is thrown. Attempts to drain a queue to itself
result in IllegalArgumentException. Further, the behavior of this operation is undefined if the specified
collection is modified while the operation is in progress.c - the collection to transfer elements intomaxElements - the maximum number of elements to transferjava.lang.UnsupportedOperationException - if addition of elements is not supported by the specified collectionjava.lang.ClassCastException - if the class of an element of this queue prevents it from being added to the specified collectionjava.lang.NullPointerException - if the specified collection is nulljava.lang.IllegalArgumentException - if the specified collection is this queue, or some property of an element of this queue prevents it
from being added to the specified collection