Atomic Reference
An AtomicReference uses CAS instruction to get and update the wrapped volatile variable to ensure lock free thread safety.
Examples
val person = AtomicReference(toImmutable(Person()))
val newPerson = toImmutable(Person())
val value = person.value
person.compareAndSet(value, newPerson)
Constructors
AtomicReference
Link copied to clipboard