If the methods are synchronized on the same monitor, then they cannot execute simultaneously in different threads. When the second thread comes to the monitor entry (the start of the synchronized method in this case), it will block until the first thread releases the monitor.
The actual state of the blocked thread in this case, as reported by jconsole, will be something like java.lang.Thread.State: WAITING (on object monitor)
Assuming all methods are normal instance methods, then they will share the same monitor when invoked on the same object. That is, if you had something like:
// Thread 1
A a1 = new A();
a1.m1();
// Thread 2
A a2 = new A();
a2.m2()
then in this case, the second thread will be able to call the method, because it's trying to obtain the implicit monitor of the a2
object, which is not locked by thread 1. But if thread 2 tried to call a1.m2()
, then it would block until thread 1 had finished executing m1()
.
If you have static methods, then they obtain the explicit monitor of the class itself (A.class
in my hypothetical-naming case), so will not be blocked by any instance method invocations.