This content has been marked as final. Show 2 replies
906738 wrote:From the Javadoc:
The wait(timeout) method will try to reacquire the lock once the timeout has expired, up to the timeout it will release the lock. I hope it is correct.
If it is so, what will happen if the another thread has holds the lock before the timeout expires, and keeps the lock after the timeout expires also,
then what state the wait timeout thread will go? Will it keeps on waiting for lock like other threads?
Thanks in advance
The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until either of the following two conditions has occurred:My understanding is that the bullets establish the condition for wait() to return, while the last line above tells us when the code following the wait() will start executing. It may not be right away.
•Another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method.
•The timeout period, specified by timeout milliseconds plus nanos nanoseconds arguments, has elapsed.
The thread then waits until it can re-obtain ownership of the monitor and resumes execution.