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,
java.util.concurrent.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))java.lang.IllegalStateException - if the element cannot be added at this time due to capacity restrictionsjava.lang.ClassCastException - if the class of the specified element prevents it from being added to this queuejava.lang.NullPointerException - if the specified element is null and this queue does not permit null elementsjava.lang.IllegalArgumentException - 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 falsejava.lang.ClassCastException - if the class of the specified element prevents it from being added to this queuejava.lang.NullPointerException - if the specified element is null and this queue does not permit null elementsjava.lang.IllegalArgumentException - if some property of this element prevents it from being added to this queuevoid put(E e) throws java.lang.InterruptedException
e - the element to addjava.lang.InterruptedException - if interrupted while waitingjava.lang.ClassCastException - if the class of the specified element prevents it from being added to this queuejava.lang.NullPointerException - if the specified element is nulljava.lang.IllegalArgumentException - if some property of the specified element prevents it from being added to this queueboolean offer(E e, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.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
availablejava.lang.InterruptedException - if interrupted while waitingjava.lang.ClassCastException - if the class of the specified element prevents it from being added to this queuejava.lang.NullPointerException - if the specified element is nulljava.lang.IllegalArgumentException - 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.