Suppose i synchronize a instance method in a class and create two objects A and B of the same class. Now when object A is accessing the synchronized method will B also be able to access it or will it have to wait until A releases the lock?
posted 5 years ago
They lock different objects (the instance in question), so the methods will be able to run at the same time.
If you synchronized a static method, that locks the class object, and so then any call can block any other.