Java / Concurrent collections
Explain DelayQueue in Java Concurrent collections.
DelayQueue class implements the BlockingQueue interface. It is introduced in Java 1.5.
DelayQueue is an unbounded blocking queue of Delayed elements, in which an element can only be taken when its delay has expired. The head of the queue is that Delayed element whose delay expired furthest in the past. If no delay has expired there is no head and poll will return null. Expiration occurs when an element's getDelay(TimeUnit.NANOSECONDS) method returns a value less than or equal to zero.
Even though unexpired elements cannot be removed using take or poll, they are otherwise treated as normal elements. For example, the size method returns the count of both expired and unexpired elements.
The elements of DelayQueue must implement the interface java.util.concurrent.Delayed.
This queue does not permit null elements.
More Related questions...