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 . 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 ( ); public E take ( ) throws InterruptedException; // Methods Implementing Collection public void clear ( ); public boolean contains (Object o ); public java.util.Iterator<E> iterator ( ); public boolean remove (Object o ); public int size ( ); public Object[ ] toArray ( ); public <T> T[ ] toArray (T[ ] a ); // Methods Implementing Queue public E peek ( ); public E poll ( ); // Public Methods Overriding AbstractCollection public String toString ( ); } |