March 2005
Beginner to intermediate
1254 pages
104h 21m
English
PriorityBlockingQueue<E>
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( ); ...
Read now
Unlock full access