What happens if i call wait on a notified condition variable

前端 未结 2 1897
臣服心动
臣服心动 2021-01-04 19:16

Suppose I have two threads and one shared c++ 11 condition variable. What whould happen if thread1 call notify and after that thread2 call wait? Will thread2 block forever o

2条回答
  •  死守一世寂寞
    2021-01-04 19:49

    Thread2 will block until someone calls notify. Calls to notify release threads that are waiting at the time of the call. If there are no threads waiting, they do nothing. They aren't saved.

提交回复
热议问题