Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Purpose Of Monitor.Pulse

I just want to make sure I understand something here. If I obtain a lock with Monitor.Enter or lock do I need to call Pulse before releasing the lock?

Monitor.Enter

Monitor.Pulse // Is that neccessary?

Monitor.Exit

I was always led to believe that a Monitor.Exit call would implicitly invoke Monitor.Pulse. Is that actually true?

I'm not exactly sure when would you would use Pulse. That is what is causing confusion.

like image 457
Jack Kada Avatar asked Jun 23 '10 08:06

Jack Kada


1 Answers

No, you don't need to call Pulse... but it won't be done automatically when you exit, either.

Pulse and PulseAll are used in conjunction with Wait for signalling purposes.

See the second half of this page for more details (ignore the deadlocking bit, basically :)

like image 171
Jon Skeet Avatar answered Nov 02 '22 03:11

Jon Skeet