carroll at tjc.com
Mon Nov 15 23:08:06 CET 2004
On Mon, 15 Nov 2004, Gonçalo Rodrigues wrote:
> Terry Carroll wrote:
> > What's the ordinary way of telling a thread that it's no longer needed?
> Use the queue to pass an object that the thread can recognize as an
> order to shut down.
Okay, but that was one possibility I'd mentioned. The problem is where
you have multiple consumer threads reading the Queue. Only the first
consumer will get the magic shutdown object.
What's the solution? Keep count of the number of consumer threads and
enqueue one shutdown object per consumer? (Seems icky; there has to be a
less smelly way.)
More information about the Tutor