Threading - wait()

后端 未结 2 1064
深忆病人
深忆病人 2021-01-21 06:28

The wait() method on an object can be called only in the synchronized context i.e. the current thread must have a lock on the object to invoke the wait()

2条回答
  •  伪装坚强ぢ
    2021-01-21 06:44

    wait releases the synchronized context. From the documentation:

    The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up (...)

提交回复
热议问题