fun compareAndSwap(expected: T, new: T): T
Compares value with expected and replaces it with new value if values matches.
If new value is not null and object is frozen, it must be frozen or permanent object.
Parameters
expected
- the expected value
new
- the new value
Exceptions
InvalidMutabilityException
- if the value is not frozen or a permanent object
Return the old value