有一个auto event,同时有两个线程调用WaitForSingleObject阻塞在这个事件上。

图灵转世 2011-04-09 12:27:43
有一个auto event,同时有两个线程调用WaitForSingleObject阻塞在这个事件上。当setevent这个event时,两个线程是否都将继续运行,还是只有一个线程继续运行,另一个线程还要阻塞。请各位大侠讲解。
...全文
114 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dreadnought 2011-04-09
  • 打赏
  • 举报
回复
还是只有一个线程继续运行,另一个线程还要阻塞,是这样的...当一个线程调用SetEvent后,另一个线程才会运行.如果两个线程都继续运行,那就达不到线程同步的效果了
HowToP2p 2011-04-09
  • 打赏
  • 举报
回复
When the state of a manual-reset event object is signaled, it remains signaled until it is explicitly reset to nonsignaled by the ResetEvent function. Any number of waiting threads, or threads that subsequently begin wait operations for the specified event object, can be released while the object's state is signaled.

When the state of an auto-reset event object is signaled, it remains signaled until a single waiting thread is released; the system then automatically resets the state to nonsignaled. If no threads are waiting, the event object's state remains signaled.
HowToP2p 2011-04-09
  • 打赏
  • 举报
回复
只有一个线程可以运行,另一个继续等待
Eleven 2011-04-09
  • 打赏
  • 举报
回复
只有其中的一个会运行

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧