Today I was asked this interview question and could not answer.
If you have two instances of a Person class which has a setAddress method that is synchronized. Now if it was only one object and multiple threads were accessing it, the synchronized
will make sure that only one method can access it at a time.
But if there are different objects, one thread will not wait on the other before entering the method.
Now the question is...if I wanted to make the method synchronized across all instances of Person Objects, how do I do that?