Relative Content

Tag Archive for java

How to make a method synchronized across all instances of a class

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.