You are absolutely right, only the second lock is released... but put yourself into the position of the first object. How do you know that when you call the second object's method, that it will do a wait() that is thread safe? There is no way that the JVM can know that.
And if it is thread safe, why are you still synchronized? If at the time, you call the second object, you don't need the lock,
you should release it -- use synchronized blocks, and get the method call out of the block.
And if you need the lock all the way to the point of the wait() method call, then unfortunately, you may have to refactor your algorithm. Consider using an external locking mechanism, that both objects can share.
Henry