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

On the JVM, what does @Volatile guarantee and explicitly NOT guarantee for a counter incremented from multiple threads?

@Volatile var counter: Int = 0 fun inc() { counter++ } // called concurrently