Posts

Showing posts with the label DelayQueue

Synchronized Queue

Till Java 5 (jdk1.5) developer has to take care of synchronizing queue in multi threaded application. But in Java5 new synchronized implementation java.util.concurrent.BlockingQueue has been introduced. It extends java.util.Queue and introduced few new methods like put, take etc. BlockingQueue supports additional operations that waits for the queue to become non-empty when retrieving an element from queue, and wait for space to become available in the queue when storing an element. There are following few implementation available ArrayBlockingQueue : A simple bounded BloickingQueue implementation backed by an array. DelayQueue : An unbounded blocking queue of Delayed elements, in which an element can only be taken when its delay has expired.It uses elements that implement the new java.util.concurrent.Delayed interface. PriorityBlockingQueue : This queue bases ordering on a specified Comparator , and the element returned by any take( ) call is the smallest element based on t...