does wait() relinquish currently executing object's lock ? in a synchronized method ? I am hoping the answer to be yes with a little Explanation about the protocols between notify and wait ?
Venkat Kanneganti
Ranch Hand
Joined: Nov 30, 2007
Posts: 43
posted
0
whenever wait() method is encountered by thread which releases monitor(lock) of Object ,go to wait utill some other thread enters same objects monitor and calls notify()
Peter Ricke
Greenhorn
Joined: Dec 07, 2007
Posts: 24
posted
0
does wait() relinquish currently executing object's lock ?
the thread calling wait() does not need the lock of the currently executing object but needs the lock of the object whichs wait()-method it is calling.
Here sync2() can be excecuted only by calling sync(), where the thread gets o1's Lock. direct calling of sync() results in java.lang.IllegalMonitorStateException
========<br />class a{<br /> a a(a a){return (a)a;}<br />}