Java: How can a thread wait on multiple objects?

后端 未结 8 2147
有刺的猬
有刺的猬 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:36

    You can wait only on one monitor. So notifiers must notify this one monitor. There is no other way in this low level synchronization.

提交回复
热议问题