Q:

Do we need synchronization when setting the value of an element in an ArrayList

For one thing, according to the Javadoc below:

If multiple threads access an ArrayList instance concurrently, and at least one of the threads modifies the list structurally, it must be synchronized externally. (A structural modification is any operation that adds or deletes one or more elements, or explicitly resizes the backing array; merely setting the value of an element is not a structural modification.) 

synchronization is not necessary.
For another, setting the value of an element is an atomic action so it cannot be interleaved. However, memory consistency errors are still possible. 
So which is right?
Edit: Maybe I haven't expressed myself clearly. Actually, I just wanna know whether the Javadoc is wrong or at least misleading. By the way, I said setting the value of an element is an atomic action, but this is obviously wrong.

A:

I don't think it's a good idea to make assumptions on how setting a value in ArrayList is implemented. The important thing is that if you are given no consistency guarantees in the Javadoc, you should always synchronize externally when multiple threads are using the same ArrayList.
Or, depending on the use case, choose a different structure altogether, one that was designed for concurrency, like CopyOnWriteArrayList. (Though always make sure you choose the right one, as they don't perform equally well under all circumstances.)
In this case the Javadoc doesn't explicitly say you can omit sychronization if you only use set(), merely hints at it. And the hint is wrong because as you say, memory consistency isn't guaranteed at all, you can easily end up reading stale values, or multiple set() calls can be reordered.

