Reputation: 430
Suppose we have one class in which we have one instance method and static method. We have synchronized block in static method with class level lock & we have synchronized block in instance method with object level lock. So suppose when one thread start executing static method and make class level lock , at the same time another thread try to execute instance method. So will that second thread will be blocked from execution of instance method ??
Upvotes: 0
Views: 137
Reputation: 127
the second thread will not be blocked。the class level lock & this class Object level lock,the two locks are different, but they can be re-entered each other
Upvotes: 1
Reputation: 1330
It’s possible that both static synchronized
and non static synchronized
method can run simultaneously
or concurrently
because they lock on different object.
Upvotes: 0