wait(), notify() and notifyAll() methods are always called from Synchronized block or synchronized methods only and as soon as thread enters synchronized block it acquires object lock (by holding object monitor).

1) First let’s acquire object lock by entering synchronized block.

Let’s say there is one class MyClassand we have created it’s object and reference to that object is myClass. Now we can create synchronization block, and parameter passed with synchronization tells which object has to be synchronized. In below code, we have synchronized object reference by myClass.