Yeah. I highly recommend you avoid using volatile unless you know JMM inside and out. Often times it’s better to reach for atomicity abstractions because the performance differences are tiny and you have to consider other people will need to maintain your code.
e
ephemient
05/13/2021, 5:05 PM
with Atomic*FieldUpdater volatile can have many similar operations as Atomic* wrapper types. but it'sa bit awkward to use. kotlinx.atomicfu helps