Read the API doc of the Object class's wait() and notify() methods. A lot is explained there.