Re: Producer/Consumer
- From: "Brian Gideon" <briangideon@xxxxxxxxx>
- Date: 9 Dec 2006 20:25:46 -0800
Mike,
Yep, I agree. That's one of the poorest examples of the
producer-consumer pattern I've seen.
Take a look at the producer-consumer example in the following article
for a correct version. It has been peer reviewed extensively.
http://www.yoda.arachsys.com/csharp/threads/deadlocks.shtml
Brian
mps wrote:
That is what I'm referring to. I agree that there will always be at least one
item to be dequeued when a thread is woken up, so the dequeue will never
fail. However, it is perfectly possible that all threads will be sleeping
even though there remain items in the queue (because the number of thread
wake-ups that occur may be less than the number of times the event is set).
The bottom-line is this is a completely busted implementation of a core
multithreading algorithm. Kind of embarrassing to see that up on MSDN. Makes
me wonder about the quality of the threading code in MS products :/
Mike
.
- References:
- Re: Producer/Consumer
- From: Dave Sexton
- Re: Producer/Consumer
- From: mps
- Re: Producer/Consumer
- Prev by Date: Re: Producer/Consumer
- Next by Date: Re: Street & Trip down load to PDA
- Previous by thread: Re: Producer/Consumer
- Next by thread: Re: Producer/Consumer
- Index(es):