Nidhi Sar wrote:Hold on a moment... why can't you update an object that you hold a lock to within synchronized method??
I hope that you know the difference between object and reference. Keeping that in mind, you can update an object to which you hold the lock. Example
The reason Joss' code didn't work is because we called the notify method on a different object and synchronized on a different object. The reference was the same, but the object was different. The original code does a work similar to the following code