-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Java 9 Concurrency Cookbook, Second Edition
By :

An interesting data structure provided by the Java API, which you can use in concurrent applications, is implemented in the DelayQueue
class. In this class, you can store elements with an activation date. The methods that return or extract elements from the queue will ignore these elements whose data will appear in the future. They are invisible to these methods.To obtain this behavior, the elements you want to store in the DelayQueue
class need to have the Delayed
interface implemented. This interface allows you to work with delayed objects. This interface has the getDelay()
method that returns the time until the activation of the element. This interface forces you to implement the following two methods:
compareTo(Delayed o)
: The Delayed
interface extends the Comparable
interface. This method will return a value less than zero if the object that is executing the method has a delay smaller than the object passed as a parameter. It will return...