[concurrency-interest] PriorityBlockingQueue put() operation

Michael Spiegel michael.m.spiegel at gmail.com
Sat Nov 7 15:01:07 EST 2009


Hi,

I apologize if this question has been answered before of if the answer
is trivially obvious.  The documentation for
java.util.concurrent.PriorityBlockingQueue states that the put(E e)
method will never block, and such claims are not made about the add(E
e) method.  The method bodies for both methods are identical, ignoring
the fact that one method returns boolean and the other doesn't return
a value.  The methods body is an invocation to the offer(E e) method.
I believe that offer() is a blocking method, since it locks the
ReentrantLock around the data structure.  So is put() a blocking
method? I must be missing something obvious.

Thanks!
--Michael


More information about the Concurrency-interest mailing list