I know to be thread safe one has to syncronize the get method of a primitive property, like in this class:
public class C {
private int a;
public synchronized int getA() { return a; }
public synchronized void setA(int a) { this.a= a; }
}
Is it also necessary to syncronize the get method if a is a refrence instead of a primitive?
edit: How soon will the value be updated(visible to other threads) if the getter is not synchronized. In my application, the getter is frequently called by different threads thus I want it to be unsyncronized for performance, it is ok if the getter dose not return the latest value, only the updated value never being used by other threads is not acceptable.