What's wrong with my producer-consumer queue design?

The worker threads are all blocking on the _q.WaitOne() call in DoWork(). Calling the thread's Join() method will deadlock, the threads never exit. You'll need to add a mechanism to signal to worker thread to exit.

A ManualResetEvent, tested with WaitAny in the worker, will get the job done.

You do a WaitOne() at the end of DoWork but you never set it after the threads start running. Note that AutoResetEvent will go back to not set state after a 'successful' WaitOne.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions