Multi-Threading general doubt.

  • Thread starter Thread starter deostroll
  • Start date Start date
It releases a thread from the wait queue into the ready queue.  The word  
"pulse" refers to the fact that calling Pulse() essentially signals the  
monitor just long enough for one thread to be released.  You can look the  
word up in any English dictionary if you're curious about the relevance.



In a producer/consumer pattern, when a producer adds something to a queue,  
it needs a way to notify the consumer that there's now work to be done.  
It uses the Pulse() method to release the consumer thread from the wait  
queue, if that's where it was (in the most simple producer/consumer  
implementations, it always will be any time that a producer is able to  
call Pulse(), since waiting will be the only reason the consumer releases 
the lock).

Pete

Why do we need those Monitor.Pulse() in the producer and Monitor.Wait
() in the consumer? We could have written one without those, right?

--deostroll
 
Back
Top