Java volatile reference vs. AtomicReference
Short answer is: No.
From the java.util.concurrent.atomic
package documentation. To quote:
The memory effects for accesses and updates of atomics generally follow the rules for volatiles:
get
has the memory effects of reading avolatile
variable.set
has the memory effects of writing (assigning) avolatile
variable.
By the way, that documentation is very good and everything is explained.
AtomicReference::lazySet
is a newer (Java 6+) operation introduced that has semantics unachievable through volatile
variables. See this post for more information.
No, there is not.
The additional power provided by AtomicReference is the compareAndSet() method and friends. If you do not need those methods, a volatile reference provides the same semantics as AtomicReference.set() and .get().