posted 11 years ago
Case 1 :When two threads running method1 and method2, these two threads need to be synchronized on the same A.class object.
Case 2: When two threads running method1 and method3, they don't need to be synchronized with each other as A.class object and an instance of A is not the same object.
Case 3: When two threads running method1 , they need to be synchronized on the same instance of A.class object. This is the same as case 1.
Case 4: When two threads running method3, they need to be synchronized on the same instance of A.
I hope these 4 cases can help.