gpt4 book ai didi

c++ - WaitForSingleObject - 等待队列的线程吗?

转载 作者:可可西里 更新时间:2023-11-01 13:04:50 26 4
gpt4 key购买 nike

如果我设置 3 个线程等待释放互斥锁,它们是根据请求的顺序形成一个队列,还是未定义的行为(即我们不知道哪个会先接收它) ?

最佳答案

它在 SDK article 中明确记录:

If more than one thread is waiting on a mutex, a waiting thread is selected. Do not assume a first-in, first-out (FIFO) order. External events such as kernel-mode APCs can change the wait order.

这类事件完全不受您的控制。所以“未定义的行为”是描述它的合适方式。

关于c++ - WaitForSingleObject - 等待队列的线程吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10461473/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com