Suppose I have a class where in the have methods synchronized in the way as follows.
public class Test{
public static synchronized void method1(){
}
public static synchronized void method2(){
}
public synchronized void method3(){
}
public synchronized void method4(){
}
}
So there is a scenario when two threads are calling method1
and method2
simultaneously.I feel that only one of the methods be allowed to call.What will be the case if they call method1
and method3
.Will there be a same scenario here too?what will be the case with method3
and method4
from same object?