Why synchronize on a static lock member rather than on a class?
Asked 2013-06-19T20:10:20.333
13
class Bob {
private static final Object locke = new Object();
private static volatile int value;
public static void fun(){
synchronized(locke){
value++;
}
}
}
How is this different from synchronizing on the class, i.e. synchronized(Bob.class){...}