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 either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.
Originally posted by Anvi Dixit:
Now here I think if the thread release the lock on object B tha means any other thread can acquire the lock on object B. Rigth?
E. The notify() method causes a thread to immediately release its lock.
Nirmal Seneviratne wrote:Hello guys, I have a doubt about the statement E
E. The notify() method causes a thread to immediately release its lock.
Nirmal Seneviratne wrote:
Are these statements correct? (I doubt E is incorrect because of these)
"A thread can only release its lock by exiting the synchronized code or calling wait()"
"notify() just makes the thread go to runnable state from wait state"
and neither of these statements has an effect on the first part of this question.
E. The notify() method causes a thread to immediately release its lock.
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|