What is most CPU efficient method to make the worker threads wait for tasks?

Check out this implementation of a BlockingQueue . If the queue is empty, it uses Monitor.Wait() to put the thread to sleep. When an item is added, it uses Monitor.Pulse() to wake up a thread that is sleeping on the empty queue.

You currently have Thread. Sleep(0) in your Work method for where there are no queue items. Change it to anything greater than 0 and your CPU use will go down.

Try 10 to start with...

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