When you have a method such as the following:
public synchronized void addOne() {
a++;
}
it is equivalent to the following: (correct me if I'm wrong)
public void addOne() {
synchronized(this) {
a++;
}
}
But what is the equivalent to the following method?:
public static synchronized void addOne() {
a++;
// (in this case 'a' must be static)
}
What is a synchronized block that acts the same as a static synchronized method? I understand the static synchronized method is synchronized on the class and not the instance (since there is no instance), but what is the syntax for that?