when I use the synchronized method method in an instance, the monitor is connected to 'this', and on the other hand, when I synchronize on my class (static) method, the monitor is connected to the class object, which in case I have a static variable used in the non-stationary method? will it be synchronized?
they say
public class A{
public static int reg_no = 100;
public synchronized void registration(){
A.reg_no = some operation...
}
}
in the case above, what happens to the reg_no static variable if two or more threads compete to register the method ()
source
share