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 wou开发者_运维知识库ld you would use Pulse
. That is what is causing confusion.
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 :)
精彩评论