InterviewSolution
| 1. |
What Is Delayqueue In Java Concurrency? |
|
Answer» DelayQueue is an UNBOUNDED implementation of BlockingQueue interface. DelayQueue can store elements of type Delayed only and an element can only be retrieved from DelayQueue when its delay has expired. When you implement Delayed interface two methods have to be implementedgetDelay(TIMEUNIT unit) and COMPARETO(T o). getDelay(TimeUnit unit) - Returns the remaining delay associated with this object, in the GIVEN time unit. DelayQueue is an unbounded implementation of BlockingQueue interface. DelayQueue can store elements of type Delayed only and an element can only be retrieved from DelayQueue when its delay has expired. When you implement Delayed interface two methods have to be implementedgetDelay(TimeUnit unit) and compareTo(T o). getDelay(TimeUnit unit) - Returns the remaining delay associated with this object, in the given time unit. |
|