1 *java.util.concurrent.DelayQueue* *DelayQueue* An unboundedBlockingQueue blockin
3 public class DelayQueue
4 extends |java.util.AbstractQueue|
5 implements |java.util.concurrent.BlockingQueue|
7 |java.util.concurrent.DelayQueue_Description|
8 |java.util.concurrent.DelayQueue_Fields|
9 |java.util.concurrent.DelayQueue_Constructors|
10 |java.util.concurrent.DelayQueue_Methods|
12 ================================================================================
14 *java.util.concurrent.DelayQueue_Constructors*
15 |java.util.concurrent.DelayQueue()|Creates a new DelayQueue that is initially e
16 |java.util.concurrent.DelayQueue(Collection)|Creates a DelayQueue initially con
18 *java.util.concurrent.DelayQueue_Methods*
19 |java.util.concurrent.DelayQueue.add(E)|Adds the specified element to this queu
20 |java.util.concurrent.DelayQueue.clear()|Atomically removes all of the elements
21 |java.util.concurrent.DelayQueue.drainTo(Collection)|
22 |java.util.concurrent.DelayQueue.drainTo(Collection,int)|
23 |java.util.concurrent.DelayQueue.iterator()|Returns an iterator over the elemen
24 |java.util.concurrent.DelayQueue.offer(E)|Inserts the specified element into th
25 |java.util.concurrent.DelayQueue.offer(E,long,TimeUnit)|Inserts the specified e
26 |java.util.concurrent.DelayQueue.peek()|Retrieves, but does not remove, the hea
27 |java.util.concurrent.DelayQueue.poll()|Retrieves and removes the head of this
28 |java.util.concurrent.DelayQueue.poll(long,TimeUnit)|Retrieves and removes the
29 |java.util.concurrent.DelayQueue.put(E)|Adds the specified element to this dela
30 |java.util.concurrent.DelayQueue.remainingCapacity()|Always returns Integer.MAX
31 |java.util.concurrent.DelayQueue.remove(Object)|Removes a single instance of th
32 |java.util.concurrent.DelayQueue.size()|
33 |java.util.concurrent.DelayQueue.take()|Retrieves and removes the head of this
34 |java.util.concurrent.DelayQueue.toArray()|
35 |java.util.concurrent.DelayQueue.toArray(T[])|
37 *java.util.concurrent.DelayQueue_Description*
39 An unbounded blocking queue(|java.util.concurrent.BlockingQueue|) of Delayed
40 elements, in which an element can only be taken when its delay has expired. The
41 head of the queue is that Delayed element whose delay expired furthest in the
42 past. If no delay has expired there is no head and poll will return null.
43 Expiration occurs when an element's getDelay(TimeUnit.NANOSECONDS) method
44 returns a value less than or equal to zero. This queue does not permit null
47 This class and its iterator implement all of the optional methods of the
48 (|java.util.Collection|) and (|java.util.Iterator|) interfaces.
50 This class is a member of the <a href="/../guide/collections/index.html"> Java
51 Collections Framework.
54 *java.util.concurrent.DelayQueue()*
58 Creates a new DelayQueue that is initially empty.
61 *java.util.concurrent.DelayQueue(Collection)*
63 public DelayQueue(java.util.Collection c)
65 Creates a DelayQueue initially containing the elements of the given collection
66 of (|java.util.concurrent.Delayed|) instances.
70 *java.util.concurrent.DelayQueue.add(E)*
72 public boolean add(java.util.concurrent.Delayed o)
74 Adds the specified element to this queue.
76 o - the element to add
78 Returns: true (as per the general contract of Collection.add).
79 *java.util.concurrent.DelayQueue.clear()*
83 Atomically removes all of the elements from this delay queue. The queue will be
84 empty after this call returns.
87 *java.util.concurrent.DelayQueue.drainTo(Collection)*
89 public int drainTo(java.util.Collection c)
94 *java.util.concurrent.DelayQueue.drainTo(Collection,int)*
97 java.util.Collection c,
103 *java.util.concurrent.DelayQueue.iterator()*
105 public |java.util.Iterator| iterator()
107 Returns an iterator over the elements in this queue. The iterator does not
108 return the elements in any particular order. The returned iterator is a
109 thread-safe "fast-fail" iterator that will throw
110 (|java.util.ConcurrentModificationException|) upon detected interference.
113 Returns: an iterator over the elements in this queue.
114 *java.util.concurrent.DelayQueue.offer(E)*
116 public boolean offer(java.util.concurrent.Delayed o)
118 Inserts the specified element into this delay queue.
120 o - the element to add
123 *java.util.concurrent.DelayQueue.offer(E,long,TimeUnit)*
125 public boolean offer(
126 java.util.concurrent.Delayed o,
128 java.util.concurrent.TimeUnit unit)
130 Inserts the specified element into this delay queue. As the queue is unbounded
131 this method will never block.
133 o - the element to add
134 timeout - This parameter is ignored as the method never blocks
135 unit - This parameter is ignored as the method never blocks
138 *java.util.concurrent.DelayQueue.peek()*
140 public |java.util.concurrent.Delayed| peek()
142 Retrieves, but does not remove, the head of this queue, returning null if this
143 queue has no elements with an unexpired delay.
146 Returns: the head of this queue, or null if this queue has no elements with an unexpired
148 *java.util.concurrent.DelayQueue.poll()*
150 public |java.util.concurrent.Delayed| poll()
152 Retrieves and removes the head of this queue, or null if this queue has no
153 elements with an unexpired delay.
156 Returns: the head of this queue, or null if this queue has no elements with an unexpired
158 *java.util.concurrent.DelayQueue.poll(long,TimeUnit)*
160 public |java.util.concurrent.Delayed| poll(
162 java.util.concurrent.TimeUnit unit)
163 throws |java.lang.InterruptedException|
165 Retrieves and removes the head of this queue, waiting if necessary up to the
166 specified wait time if no elements with an unexpired delay are present on this
169 timeout - how long to wait before giving up, in units of unit
170 unit - a TimeUnit determining how to interpret the timeout parameter
172 Returns: the head of this queue, or null if the specified waiting time elapses before an
173 element with an unexpired delay is present.
174 *java.util.concurrent.DelayQueue.put(E)*
176 public void put(java.util.concurrent.Delayed o)
178 Adds the specified element to this delay queue. As the queue is unbounded this
179 method will never block.
181 o - the element to add
183 *java.util.concurrent.DelayQueue.remainingCapacity()*
185 public int remainingCapacity()
187 Always returns Integer.MAX_VALUE because a DelayQueue is not capacity
191 Returns: Integer.MAX_VALUE
192 *java.util.concurrent.DelayQueue.remove(Object)*
194 public boolean remove(java.lang.Object o)
196 Removes a single instance of the specified element from this queue, if it is
200 *java.util.concurrent.DelayQueue.size()*
207 *java.util.concurrent.DelayQueue.take()*
209 public |java.util.concurrent.Delayed| take()
210 throws |java.lang.InterruptedException|
212 Retrieves and removes the head of this queue, waiting if no elements with an
213 unexpired delay are present on this queue.
216 Returns: the head of this queue
217 *java.util.concurrent.DelayQueue.toArray()*
219 public |java.lang.Object| toArray()
224 *java.util.concurrent.DelayQueue.toArray(T[])*
226 public |java.lang.Object| toArray(java.lang.Object[] array)