exchangeAt
Atomically stores the new value into the element of this AtomicArray at the given index and returns the old value of the element.
Since Kotlin
2.1Throws
if the index is out of bounds of this array.
Samples
import kotlin.concurrent.atomics.*
fun main() {
//sampleStart
val a = AtomicArray(arrayOf("aaa", "bbb", "ccc"))
println(a.exchangeAt(1, "kkk")) // bbb
println(a.loadAt(1)) // kkk
println(a.toString()) // [aaa, kkk, ccc]
//sampleEnd
}
Atomically stores the new value into the element of this AtomicArray at the given index and returns the old value of the element.
Since Kotlin
2.1Throws
if the index is out of bounds of this array.
Atomically stores the new value into the element of this AtomicArray at the given index and returns the old value of the element.
Has the same memory effects as java.util.concurrent.atomic.AtomicReferenceArray.getAndSet.
Since Kotlin
2.1Throws
if the index is out of bounds of this array.
Atomically stores the new value into the element of this AtomicArray at the given index and returns the old value of the element.
Since Kotlin
2.1Throws
if the index is out of bounds of this array.
Atomically stores the new value into the element of this AtomicArray at the given index and returns the old value of the element.
Since Kotlin
2.1Throws
if the index is out of bounds of this array.
Atomically stores the new value into the element of this AtomicArray at the given index and returns the old value of the element.
Since Kotlin
2.1Throws
if the index is out of bounds of this array.