I'm doing a simple Producer/Consumer thing based on the example in the Sun
docs, where the Consumer does a wait until there is something to consume,
then it consumes it and does a notify, and the Producer does a wait until
there is nothing to consume and then adds it and does a notify. But now I
need a bunch of Consumers. Is there a standard design pattern for this,
or am I going to have to figure it out myself?

Signature
Paul Tomblin <ptomblin@xcski.com> http://blog.xcski.com/
Do you have a point, or are you saving it for a special occasion?
-- David P. Murphy
Patrick May - 28 Sep 2007 01:04 GMT
> I'm doing a simple Producer/Consumer thing based on the example in
> the Sun docs, where the Consumer does a wait until there is
[quoted text clipped - 3 lines]
> there a standard design pattern for this, or am I going to have to
> figure it out myself?
This is a standard JavaSpaces' Master-Worker pattern. See
http://www.jini.org for general information on JavaSpaces and just
Google "javaspaces master worker" for numerous examples.
Regards,
Patrick
------------------------------------------------------------------------
S P Engineering, Inc. | Large scale, mission-critical, distributed OO
| systems design and implementation.
pjm@spe.com | (C++, Java, Common Lisp, Jini, middleware, SOA)
Hunter Gratzner - 28 Sep 2007 01:24 GMT
> I'm doing a simple Producer/Consumer thing based on the example in the Sun
> docs, where the Consumer does a wait until there is something to consume,
> then it consumes it and does a notify, and the Producer does a wait until
> there is nothing to consume and then adds it and does a notify. But now I
> need a bunch of Consumers.
http://java.sun.com/javase/6/docs/api/java/util/concurrent/BlockingQueue.html
pay special attention to the code example.
Paul Tomblin - 28 Sep 2007 02:04 GMT
In a previous article, Hunter Gratzner <a24900@googlemail.com> said:
>> there is nothing to consume and then adds it and does a notify. But now I
>> need a bunch of Consumers.
>
>http://java.sun.com/javase/6/docs/api/java/util/concurrent/BlockingQueue.html
>
>pay special attention to the code example.
I knew there was a reason why I liked Java 1.5.
Thanks.

Signature
Paul Tomblin <ptomblin@xcski.com> http://blog.xcski.com/
When my ship comes in, I'll be waiting at the airport.
Lew - 28 Sep 2007 02:49 GMT
> In a previous article, Hunter Gratzner <a24900@googlemail.com> said:
>>> there is nothing to consume and then adds it and does a notify. But now I
[quoted text clipped - 4 lines]
>
> I knew there was a reason why I liked Java 1.5.
There are several idioms. /Java Concurrency in Practice/ by Brian Goetz, et
al., discusses a few of them.

Signature
Lew