public interface Pollable<E>
BlockingQueue interface| Modifier and Type | Method and Description |
|---|---|
int |
drainTo(Collection<? super E> c)
Removes all available elements from this queue and adds them to the given collection.
|
int |
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.
|
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,
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.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.NoSuchElementException - if this queue is emptyE peek()
null if this queue is empty.null if this queue is emptyE take() throws InterruptedException
InterruptedException - if interrupted while waitingE poll(long timeout, TimeUnit unit) throws 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
availableInterruptedException - if interrupted while waitingint drainTo(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 intoUnsupportedOperationException - if addition of elements is not supported by the specified collectionClassCastException - if the class of an element of this queue prevents it from being added to the specified collectionNullPointerException - if the specified collection is nullIllegalArgumentException - 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(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 transferUnsupportedOperationException - if addition of elements is not supported by the specified collectionClassCastException - if the class of an element of this queue prevents it from being added to the specified collectionNullPointerException - if the specified collection is nullIllegalArgumentException - if the specified collection is this queue, or some property of an element of this queue prevents it
from being added to the specified collectionCopyright © 2022 Internet2. All rights reserved.