compareAndExchange
Deprecated (with error)
Use compareAndExchangeAt(index: Int, expectedValue: T, newValue: T) instead.
Replace with
this.compareAndExchangeAt(index, expectedValue, newValue)
Content copied to clipboard
Atomically sets the value of the element at the given index to the new value if the current value equals the expected value and returns the old value of the element in any case.
Provides sequential consistent ordering guarantees and never fails spuriously.
Since Kotlin
2.1Throws
if the index is out of bounds of this array.