Example from Enthuware mock
test :
The answer is :
One can be certain that none of the letters i, j and k will ever be printed during execution.
My question is how do you decide what object to synchronize on ? In the above example they synchronized on what seems to me to be an object that has got nothing to do with the rest of the code.
In the above example, could I make an instance of any class I have, lets say for example class Animal and then synchronize on that instead of Object to do the above code ?
I guess I'm a bit confused when to synchronize on an object (and what object) and when to synchronize on 'this'.
Is there some concept I'm not getting here ?