[concurrency-interest] Use of blocked queues

David Holmes dholmes at dltech.com.au
Mon May 30 18:41:29 EDT 2005


Calum MacLean writes:
> I can achieve this relatively easily directly, by using a common
> object for synchronising around, and keeping a note of the number of
readers.
> But I thought that part of the raison-d'etre of java.util.concurrency
> was so that most uses of concurrency could use the higher level constructs
(queues
> etc.), and not have to worry about using locks etc. directly.

j.u.c provides a toolkit for a wide range of uses - some things higher-level
than others, but ultimately it comes down to application needs: you use the
tools that do the job best.

I still can't quite grasp exactly what you need, but based on the statement
above would it suffice to simply have your readers increment an
AtomicInteger before taking from the queue and decrement it after - the
count then tracks very approximately how many reads are in progress?

Cheers,
David Holmes



More information about the Concurrency-interest mailing list