开发者

Purpose Of Monitor.Pulse

开发者 https://www.devze.com 2023-01-04 05:53 出处:网络
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?

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 :)

0

精彩评论

暂无评论...
验证码 换一张
取 消