DelayQueue (Java SE 26 & JDK 26)
- Type Parameters:
E- the type of elements held in this queue
- All Implemented Interfaces:
Iterable<E>, Collection<E>, BlockingQueue<E>, Queue<E>
-
Constructor Summary
Constructors
Creates a new
DelayQueuethat is initially empty.Creates a
DelayQueueinitially containing the elements of the given collection ofDelayedinstances. -
Method Summary
booleanInserts the specified element into this delay queue.
voidclear()Atomically removes all of the elements from this delay queue.
intRemoves all available elements from this queue and adds them to the given collection.
intRemoves at most the given number of available elements from this queue and adds them to the given collection.
iterator()Returns an iterator over all the elements (both expired and unexpired) in this queue.
booleanInserts the specified element into this delay queue.
booleanInserts the specified element into this delay queue.
peek()Retrieves, but does not remove, the head of this queue, or returns
nullif this queue is empty.poll()Retrieves and removes the expired head of this queue, or returns
nullif this queue has no expired elements.Retrieves and removes the expired head of this queue, waiting if necessary until an expired element is available on this queue, or the specified wait time expires.
voidInserts the specified element into this delay queue.
intAlways returns
Integer.MAX_VALUEbecause aDelayQueueis not capacity constrained.remove()Retrieves and removes the expired head of this queue, or throws an exception if this queue has no expired elements.
booleanRemoves a single instance of the specified element from this queue, if it is present, whether or not it has expired.
intsize()Returns the number of elements in this collection.
take()Retrieves and removes the expired head of this queue, waiting if necessary until an expired element is available on this queue.
toArray()Returns an array containing all of the elements in this queue.
<T> T[]toArray(T[] a) Returns an array containing all of the elements in this queue; the runtime type of the returned array is that of the specified array.
Methods declared in class AbstractQueue
booleanAdds all of the elements in the specified collection to this queue.
Retrieves, but does not remove, the head of this queue.
Methods declared in class AbstractCollection
contains, containsAll, isEmpty, removeAll, retainAll, toStringbooleanReturns
trueif this collection contains the specified element.booleanReturns
trueif this collection contains all of the elements in the specified collection.booleanReturns
trueif this collection contains no elements.booleanRemoves all of this collection's elements that are also contained in the specified collection (optional operation).
booleanRetains only the elements in this collection that are contained in the specified collection (optional operation).
Returns a string representation of this collection.
Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitCreates and returns a copy of this object.
booleanIndicates whether some other object is "equal to" this one.
protected voidDeprecated, for removal: This API element is subject to removal in a future version.
Returns the runtime class of this
Object.intReturns a hash code value for this object.
final voidWakes up a single thread that is waiting on this object's monitor.
final voidWakes up all threads that are waiting on this object's monitor.
final voidCauses the current thread to wait until it is awakened, typically by being notified or interrupted.
final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
Methods declared in interface BlockingQueue
booleanReturns
trueif this queue contains the specified element.Methods declared in interface Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArraybooleanCompares the specified object with this collection for equality.
intReturns the hash code value for this collection.
Returns a possibly parallel
Streamwith this collection as its source.default booleanRemoves all of the elements of this collection that satisfy the given predicate (optional operation).
Creates a
Spliteratorover the elements in this collection.Returns a sequential
Streamwith this collection as its source.default <T> T[]Returns an array containing all of the elements in this collection, using the provided
generatorfunction to allocate the returned array.
-
Constructor Details
-
DelayQueue
-
DelayQueue
-
-
Method Details
-
add
-
offer
-
put
-
offer
-
poll
-
take
-
poll
-
remove
-
peek
-
size
-
drainTo
-
drainTo
-
clear
-
remainingCapacity
-
toArray
-
toArray
-
remove
-
iterator
-