How many locks does PriorityBlockingQueue have?
Are the take and put operations synchronized?
I couldnt find much information regarding this type of queue. I was using the single threaded PriorityQueue.
How many locks does PriorityBlockingQueue have? Are the take and put operations synchronized? I
Share
That is an implementation detail that does not matter. Unless you want to understand how it is implemented in which case I can only suggest that you looked at the source code.
They are probably not synchronized strictly speaking, but the class is thread safe so you can take and put simultaneously in several threads.
Note: the javadoc of
PriorityBlockingQueueis not very explicit on that point, but if you look at the javadoc of the java.util.concurrent package, you will see:And
BlockingQueueclearly states: