fetchAndAddAt
Atomically adds the given delta to the element of this AtomicLongArray 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 = AtomicLongArray(longArrayOf(1, 2, 3))
// Returns the old value before the addition.
println(a.fetchAndAddAt(1, 10)) // 2
println(a.loadAt(1)) // 12
println(a.toString()) // [1, 12, 3]
//sampleEnd
}
Atomically adds the given delta to the element of this AtomicLongArray 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 adds the given delta to the element of this AtomicLongArray at the given index and returns the old value of the element.
Has the same memory effects as java.util.concurrent.atomic.AtomicLongArray.getAndAdd.
Since Kotlin
2.1Throws
if the index is out of bounds of this array.
Atomically adds the given delta to the element of this AtomicLongArray 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 adds the given delta the element of this AtomicLongArray at the given index by and returns the old value of the element.
Since Kotlin
2.1Throws
if the index is out of bounds of this array.
Atomically adds the given delta the element of this AtomicLongArray at the given index by and returns the old value of the element.
Since Kotlin
2.1Throws
if the index is out of bounds of this array.