Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardKotlinVolatile and atomics on JVMSingle-choice MCQ

AtomicReference<T> exposes lazySet (and there are weakCompareAndSet variants). How does lazySet differ from a normal volatile set in JMM terms?

val ref = java.util.concurrent.atomic.AtomicReference("a") ref.lazySet("b") // vs ref.set("b")