What is the absolute fastest way to implement a concurrent queue with ONLY one consumer and one producer?
Posted
by
JohnPristine
on Stack Overflow
See other posts from Stack Overflow
or by JohnPristine
Published on 2012-04-04T22:21:54Z
Indexed on
2012/04/04
23:29 UTC
Read the original article
Hit count: 153
java.util.concurrent.ConcurrentLinkedQueue
comes to mind, but is it really optimum for this two-thread scenario? I am looking for the minimum latency possible on both sides (producer and consumer). If the queue is empty you can immediately return null AND if the queue is full you can immediately discard the entry you are offering.
Does ConcurrentLinkedQueue use super fast and light locks (AtomicBoolean) ? Has anyone benchmarked ConcurrentLinkedQueue or knows about the ultimate fastest way of doing that?
Additional Details: I imagine the queue should be a fair one, meaning the consumer should not make the consumer wait any longer than it needs (by front-running it) and vice-versa.
© Stack Overflow or respective owner