private static class C {
Set<String> myset;
public Set<String> get() {
return myset;
}
public void set() {
myset = new HashSet<>();
}
}
I have once C class instance and multiple threads calling get and set. Is this thread safe without synchronized block? I think it is since assignment is atomic.