Possible Duplicate:
What is the difference between synchronized and static synchronized?
What is the advantage having object lock over class lock?
For example,
public static void log2(String msg1, String msg2){
synchronized(MyClass.class){
log.writeln(msg1);
log.writeln(msg2);
}
}
and,
public void log2(String msg1, String msg2){
synchronized(this){
log.writeln(msg1);
log.writeln(msg2);
}
}