fetchAndAdd

expect fun fetchAndAdd(delta: Int): Int(source)

Atomically adds the given value to the current value of this AtomicInt and returns the old value.

Since Kotlin

2.1

Samples

import kotlin.concurrent.atomics.*
import kotlin.concurrent.thread

fun main() { 
   //sampleStart 
   val a = AtomicInt(7)
// Returns the old value before the addition.
println(a.fetchAndAdd(10)) // 7
println(a.load()) // 17 
   //sampleEnd
}
actual fun fetchAndAdd(delta: Int): Int(source)

Atomically adds the given value to the current value of this AtomicInt and returns the old value.

Since Kotlin

2.1
actual fun fetchAndAdd(delta: Int): Int(source)

Atomically adds the given value to the current value of this AtomicInt and returns the old value.

Has the same memory effects as java.util.concurrent.atomic.AtomicInteger.getAndAdd.

Since Kotlin

2.1
actual fun fetchAndAdd(delta: Int): Int(source)

Atomically adds the given value to the current value of this AtomicInt and returns the old value.

Since Kotlin

2.1
actual fun fetchAndAdd(delta: Int): Int(source)

Atomically adds the given value to the current value of this AtomicInt and returns the old value.

Since Kotlin

2.1
actual fun fetchAndAdd(delta: Int): Int(source)

Atomically adds the given value to the current value of this AtomicInt and returns the old value.

Since Kotlin

2.1