The execution of the myMethod enters the object monitor at the beginning of the method and holds it until it ends. Any operations performed inside the method are synchronized , but all parameters of the call are evaluated before the call is made, therefore generateParameter not executed inside the lock window myMethod .
If generateParameter has any kind of synchronization, it can compete for the same lock, because without an explicit synchronization object, the JVM synchronizes with the object whose method is called.
I highly recommend profiling the code to determine where it really gets stuck.
source share