atomicLazy
Error since 2.1
fun <T> atomicLazy(initializer: () -> T): Lazy<T>(source)
import kotlin.native.concurrent.atomicLazy
class Demo {
// Lazily initialized property that is thread‑safe
val expensiveValue: Int by atomicLazy {
println("Computing value")
42
}
fun printValue() {
// The initializer runs only once, even if called from multiple threads
println("Value: $expensiveValue")
}
}