spierce7
07/12/2018, 2:58 AM@Frozen
class AtomicInt(private var value: Int = 0) {
// ...
}
If you have a var in a frozen object, how can you still mutate the value of that var? I thought it was unchangeable after it is frozen. What am I misunderstanding?olonho
07/12/2018, 7:44 AMfrozen is not the same as immutable, more like mutable using concurrency-safe APIsspierce7
07/12/2018, 2:03 PMfrozen doesn't enforce the use of concurrency safe APIs though, does it (how would it?)? It seems like it's still very easy to have race conditions with frozen. If I'm now seeing the whole picture, I now don't understand how Kotlin/native's threading model is an improvement over Java. If I mark something as frozen, it seems like I can have shared mutable state between threads just as easily as I do in Java. What am I missing? How is Kotlin/native's threading model an improvement over Java if that's the case?olonho
07/12/2018, 2:16 PMfrozen means immutable wrt regular field modifications, Atomic[Int|Long|Reference] are intentional exception to that rule, as atomic values API allows concurrency-safe modification.spierce7
07/12/2018, 2:27 PM