Hello everyone,


Here is the description about when to use Pulse and when to use PulseAll to achieve best performance.

My question is, I do not quite understand this situation, "Sometimes, however, different threads are waiting on different conditions, but all waiting on the same monitor. In that case, you need to use PulseAll so that you make sure that the thread which is waiting for whatever condition has just occurred is able to notice it and make progress."? Could anyone show a scenario about what means "different threads are waiting on different conditions, but all waiting on the same monitor" please?

(the link and related whole paragraph is quoted below)

http://www.yoda.arachsys.com/csharp/...eadlocks.shtml

--------------------
The reason for having both Pulse and PulseAll is for different situations, where you're waiting on different conditions. If either there'll only be one thread waiting, or (as is the case above) any thread can consume any produced object, you can just use Pulse. If there are several threads waiting on the object, that ends up being more efficient than PulseAll - there's no point in waking up a bunch of threads if you know that only one of them is going to be able to make progress, and that it doesn't matter which you wake up. Sometimes, however, different threads are waiting on different conditions, but all waiting on the same monitor. In that case, you need to use PulseAll so that you make sure that the thread which is waiting for whatever condition has just occurred is able to notice it and make progress.
--------------------


thanks in advance,
George