OCMJD 6, OCPJP8, CISSP Baroque Potion, G+
Himai Minh wrote:Lock and unlock will prevent two threads making the same room reservation.
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.
alan dunne wrote:As the three methods are synchronized on the Data instance, i really should not have to synchronize on the lockedRecordsMap as well. But then how do I notify the second thread that the record has been unlcoked() as notify must be called from a synchronized block?
Consider Paul's rocket mass heater. |