When to prefer LinkedBlockingQueue
over ArrayBlockingQueue
?
Which data structure to use among LinkedBlockingQueue
and ArrayB
From the JavaDoc for ArrayBlockingQueue
A bounded blocking queue backed by an array.
Emphasis mine
From the JavaDoc for LinkedBlockingQueue:
An optionally-bounded blocking queue based on linked nodes.
Emphasis mine
So if you need a bounded queue you can use either, if you need an unbounded queue you must use LinkedBlockingQueue
.
For a bounded queue, then you would need to benchmark to work out which is better.