calling Object.notify() before Object.wait()

后端 未结 4 1679
独厮守ぢ
独厮守ぢ 2021-01-06 03:46

If there is no thread which is waiting, using Object.wait() , any calls to Object.notify() or Object.notifyAll() have no effect. I hav

4条回答
  •  死守一世寂寞
    2021-01-06 04:22

    This kind of scenario seems to be a perfect fit for a Semaphore. Call Semaphore.release() instead of notify() and Semaphore.acquire() instead of wait.

提交回复
热议问题