compareAndSwap
Compares value with expected and replaces it with new value if values matches. Note that comparison is identity-based, not value-based. If new value is not null, it must be frozen or permanent object.
Since Kotlin
1.3Return
the old value
Parameters
expected
the expected value
new
the new value
Throws
if the value is not frozen or a permanent object