[concurrency-interest] Asynchronous-nature of ConcurrentLinkedQueue
martinrb at google.com
Tue May 18 18:40:04 EDT 2010
On Tue, May 18, 2010 at 15:28, Gregg Wonderly <gergg at cox.net> wrote:
> And I guess I am always curious why there is no "counter" associated with
> the queue length. It would provide the same "rough" estimate as the
> "traversal" without the repeated overhead would it not?
You could do that, but you would need an AtomicInteger
to keep track of the count. And that requires expensive CASes,
and unavoidable contention between consumers and producers.
Unless you have super-fancy counters that have not yet
been proven in practice.
More information about the Concurrency-interest