Java: How can a thread wait on multiple objects?

后端 未结 8 2093
有刺的猬
有刺的猬 2020-12-30 23:46

A thread can use Object.wait() to block until another thread calls notify() or notifyAll() on that object.

But what if a threa

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-31 00:37

    They could all use the same mutex. You consumer is waiting on that mutex, the both other notify on that mutex when the first can proceed.

提交回复
热议问题