views:

45

answers:

2

Is there any implementation of blocking queue which guarantees fair take() operation if multiple consumers are removing element from the same queue. I checked LinkedBlockingQueue, LinkedTransferQueue and looks like both of them are unfair. ArrayBlockingQueue provides fair operation but its bounded.

A: 

PriorityBlockingQueue

Woot4Moo
+2  A: 

Fairness policy may be specified for SynchronousQueue:

a queue constructed with fairness set to true grants threads access in FIFO order

Vasil Remeniuk
Looking at the javadoc for that class it makes me laugh. For instance clear does nothing
Woot4Moo
@Woot4Moo you clearly (pun unintended) don't understand how that class works – it has no capacity at all so it can't be cleared.
Jed Wesley-Smith
@Jed you clearly don't find the humor in documenting something that does nothing.
Woot4Moo