In Java there exists an AtomicReference class. Does this mean that setting a reference is NOT an atomic operation in and of itself?
e.g., is this not thread-safe (assuming that the value returned cannot be modified)?:
public void someMethod()
{
this.someList = Collections.unmodifiableList(new LinkedList<Object>());
}
public List<Object> getReadOnlyList()
{
return someList;
}
How about in C#?
According to the Java Language Specification, version 3.0, Section 17.7:
AtomicReference enables performing a compare and set as an atomic action.
This isn't threadsafe: