are atomicfu classes mutable by any thread?
# kotlin-native
k
are atomicfu classes mutable by any thread?
Atomic references for Kotlin/Native are based on FreezableAtomicReference and every reference that is stored to the previously frozen (shared with another thread) atomic is automatically frozen, too.
k
Interesting. I think, I should test it.
As per document it mutable for all threads.
b
They are. The idea is that you can create a new immutable object and then assign it to the atomic reference.
Copy code
val someVal = atomic("hello")
//value of someVal is now "hello"
launch(Dispatchers.Default) {
  someVal.value = "world"
}
//value of someVal is now "world"