[concurrency-interest] Blocking queue

Grace Kwok gykwok at yahoo.com
Wed May 17 21:44:48 EDT 2006

Presumably, the takeType2BeforeType1Task() method
waits for anyQueueNotEmpty.  But the one who signals
it is the put(type2obj).  So, the
takeType2BeforeType1Task() method would really only be
the takeType2Task() method if I understand correctly.

Thanks, Grace

On 5/17/06, Dawid Kurzyniec <dawidk at mathcs.emory.edu>

    I'd implement it by writing a custom blocking
queue implementation (not
    necessarily implementing the BlockingQueue
interface) using two
    non-blocking queues internally and providing its
own wait/notification
    mechanisms on top of that, using condition
variables. For instance,
    type1queueNotEmpty, anyQueueNotEmpty,
type1queueNotFull, and
    type2queueNotFull might be your conditions; the
put(type2obj) would
    await on type2queueNotFull, then put, then signal
anyQueueNotEmpty. Your
    "takeType1task()" would wait on
type1queueNotEmpty, then take, then
    signal type1queueNotFull, etc.


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

More information about the Concurrency-interest mailing list