Hi, Simon,
I think you make a mistake here.
If a thread is accessing a method, which is marked as synchronized, the thread will need the lock of the object that is represented by the class the method is defined in. Ergo, no other thread would be able to access any other synchronized methods in the same class.
This is true only for static method. For instance method, the lock is on the receiver object. As long as the reciever object is different,
two threads can concurrently enter synchronized method that operate on different object of the same class.
once one of threads enters one of the synchronized methods in the ZZ class, the other thread can't enter the other method until it has finished...
Please see the modified example of yours below.
From the running result, you can see that, thread-0 and thread-1 can concurrently run aMethod() and bMethod(). As sleep() method do not give up lock, this example demonstrate that the two thread keep two different lock, which belongs to two instance of the same class.
Hope I made my point clear.
