WaitForSingleObject - do threads waiting form a queue?

后端 未结 5 522
庸人自扰
庸人自扰 2021-01-18 06:04

If I set 3 threads to wait for a mutex to be release, do they form a queue based on the order they requested it in or is it undefined behaviour (i.e. we don\'t know which on

5条回答
  •  借酒劲吻你
    2021-01-18 06:30

    There seem to be very mixed opinions about this and no clear information anywhere. In this thread: http://us.generation-nt.com/answer/are-events-fair-help-38447612.html some people seem to suggest that fairness of events is implemented using a simple fifo queue that ignores priorities, while others are saying that fairness should not be assumed.

    Bottom line, I think you're better off not basing your logic on fairness, or wrapping an event with your own implementation that guarantees fairness.

提交回复
热议问题