Agree for *variables*. Here, we have a class member, which has to be loaded, then incremented, then stored.
So as Bertrand, I stay on the safe side and synchronize.
Just to be clear, what you're suggesting is to do:
public class MyClass {private int counter;
public someMethod() {
...
synchronized(this) {
++counter;
}
...
}
...
}?
I don't think it is necessary, and could hurt performance, but before I try to dig up some other reference, I'd like to know if we're talking about the same scenario.
Ugo
