到底用不用CSingleLock和CMultiLock ?

力为 力为 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
MSDN这样说的:
In order to use the synchronization classes CSemaphore, CMutex, CCriticalSection, and CEvent, you must create either a CSingleLock or CMultiLock object to wait on and release the synchronization object.

但又这样说的:
Alternatively, you can create a CSemaphore object stand-alone, and access it explicitly before attempting to access the controlled resource. This method, while clearer to someone reading your source code, is more prone to error.

前面说必须用CSingleLock 或 CMultiLock ,后面说可以不用。
但到底是用还是不用呢?
不用会容易发生什么错误呢?
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
力为
力为 领域专家: C/C++技术领域 领域专家: C/C++技术领域
进程/线程/DLL 15,466 成员 49,169 内容