为什么必须从同步的代码块内调用Wait方法 [英] why The Wait methods must be invoked from within a synchronized block of code

查看:261
本文介绍了为什么必须从同步的代码块内调用Wait方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么必须从同步代码块内调用Pulse,PulseAll和Wait方法.

why The Pulse, PulseAll, and Wait methods must be invoked from within a synchronized block of code

推荐答案

所有这三种方法都会临时释放您拥有的锁.如果您没有锁,就无法释放它,即使是暂时的也不行.这就像放弃不属于您的东西:)
All three methods temporarily release the lock that you own. If you don''t own a lock, you cannot release it, even temporarily. It would be similar to giving up something that''s not yours :)


这篇关于为什么必须从同步的代码块内调用Wait方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆