public interface Offerable<E>
BlockingQueue interface.| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e)
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity
restrictions, returning
true upon success and throwing an IllegalStateException if no space is
currently available. |
boolean |
offer(E e)
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity
restrictions.
|
boolean |
offer(E e,
long timeout,
TimeUnit unit)
Inserts the specified element into this queue, waiting up to the specified wait time if necessary for space to
become available.
|
void |
put(E e)
Inserts the specified element into this queue, waiting if necessary for space to become available.
|
int |
remainingCapacity()
Returns the number of additional elements that this queue can ideally (in the absence of memory or resource
constraints) accept without blocking, or
Integer.MAX_VALUE if there is no intrinsic limit. |
boolean add(E e)
true upon success and throwing an IllegalStateException if no space is
currently available.e - the element to addtrue (as specified by Collection.add(E))IllegalStateException - if the element cannot be added at this time due to capacity restrictionsClassCastException - if the class of the specified element prevents it from being added to this queueNullPointerException - if the specified element is null and this queue does not permit null elementsIllegalArgumentException - if some property of this element prevents it from being added to this queueboolean offer(E e)
add(E), which
can fail to insert an element only by throwing an exception.e - the element to addtrue if the element was added to this queue, else falseClassCastException - if the class of the specified element prevents it from being added to this queueNullPointerException - if the specified element is null and this queue does not permit null elementsIllegalArgumentException - if some property of this element prevents it from being added to this queuevoid put(E e) throws InterruptedException
e - the element to addInterruptedException - if interrupted while waitingClassCastException - if the class of the specified element prevents it from being added to this queueNullPointerException - if the specified element is nullIllegalArgumentException - if some property of the specified element prevents it from being added to this queueboolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException
e - the element to addtimeout - how long to wait before giving up, in units of unitunit - a TimeUnit determining how to interpret the timeout parametertrue if successful, or false if the specified waiting time elapses before space is
availableInterruptedException - if interrupted while waitingClassCastException - if the class of the specified element prevents it from being added to this queueNullPointerException - if the specified element is nullIllegalArgumentException - if some property of the specified element prevents it from being added to this queueint remainingCapacity()
Integer.MAX_VALUE if there is no intrinsic limit.
Note that you cannot always tell if an attempt to insert an element will succeed by inspecting
remainingCapacity because it may be the case that another thread is about to insert or remove an element.
Copyright © 2022 Internet2. All rights reserved.