由买买提看人间百态

topics

全部话题 - 话题: openmutex
(共0页)
p***o
发帖数: 1252
1
来自主题: Programming版 - mutex一问
你的需求是啥?没法open自然能检测出来:
OpenMutex
Return Value
...
If a named mutex does not exist, the function fails and GetLastError returns
ERROR_FILE_NOT_FOUND.
还有这一段:
If your multi-threaded application must repeatedly create, open, and close
a named mutex object, a race condition can occur. In this situation, it is b
etter to use CreateMutex instead of OpenMutex, because CreateMutex opens a m
utex if it exists and creates it if it does not.
c*****z
发帖数: 182
2
来自主题: Programming版 - mutex一问
刚看了书上说win32里的mutex用了reference counting,如果没有线程引用它的话就自
动销毁。很困惑:假设线程A调用createmutex生成了个mutex,然后该线程没用它就退
出了。线程B想通过openmutex打开A产生的mutex,那如果A先退出了,此时是不是mutex
就被销毁了,B打不开了那?
(共0页)