加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – std :: mutex的线程安全性

发布时间:2020-12-16 10:35:13 所属栏目:百科 来源:网络整理
导读:我可以在一个线程中锁定std :: mutex并在其他线程中解锁吗?这是没有任何具体工程背景的理论问题.我只是好奇. 解决方法 C标准,[thread.mutex.requirements.mutex] / 21和22: The expression m.unlock() shall be well-formed and have the following semant
我可以在一个线程中锁定std :: mutex并在其他线程中解锁吗?这是没有任何具体工程背景的理论问题.我只是好奇.

解决方法

C标准,[thread.mutex.requirements.mutex] / 21和22:

The expression m.unlock() shall be well-formed and have the following semantics:

? ? ??Requires: The calling thread shall own the mutex.

违反Requires子句中的要求会导致未定义的行为.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读