What happens when I assign a new instance of AtomicIntegerArray to a variable in a multithreaded environment?
AtomicIntegerArray array = new AtomicIntegerArray(...);
do some stuff
array = new AtomicIntegerArray(...);
Might some threads still access the stale reference to the old instance after the new assignment? If so, would I need to declare the atomic array as volatile as well?
if
arrayis visible to other threads (e.g. a class member variable) then yes, it would need to be volatile as well.