Name

PriorityBlockingQueue<E>

Synopsis

This threadsafe class implements the BlockingQueue interface. It is an unbounded queue that orders its elements according to a Comparator, or, for Comparable elements, according to their compareTo( ) method. The head of the queue (the next element to be removed) is always the smallest element. Note that the Iterator returned by the iterator( ) method is not guaranteed to return elements in this order. See also java.util.PriorityQueue.

java.util.concurrent.PriorityBlockingQueue<E>

Figure 16-87. java.util.concurrent.PriorityBlockingQueue<E>

public class PriorityBlockingQueue<E> extends java.util.AbstractQueue<E>
 implements BlockingQueue<E>, Serializable {
// Public Constructors
     public PriorityBlockingQueue( );  
     public PriorityBlockingQueue(int initialCapacity);  
     public PriorityBlockingQueue(java.util.Collection<? extends E> c);  
     public PriorityBlockingQueue(int initialCapacity, java.util.Comparator<? super E> 
        comparator);  
// Public Instance Methods
     public java.util.Comparator<? super E> comparator( );  
// Methods Implementing BlockingQueue
     public boolean add(E o);  
     public int drainTo(java.util.Collection<? super E> c);  
     public int drainTo(java.util.Collection<? super E> c, int maxElements);  
     public boolean offer(E o);  
     public boolean offer(E o, long timeout, TimeUnit unit);  
     public E poll(long timeout, TimeUnit unit) throws InterruptedException;  
     public void put(E o);  
     public int remainingCapacity( ); ...

Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.