addAndFetch
Atomically adds the given value to the current value of this AtomicLong and returns the new value.
Since Kotlin
2.1Samples
import kotlin.concurrent.atomics.*
import kotlin.concurrent.thread
fun main() {
//sampleStart
val a = AtomicLong(7)
// Returns the new value after the addition.
println(a.addAndFetch(10)) // 17
println(a.load()) // 17
//sampleEnd
}
Atomically adds the given value to the current value of this AtomicLong and returns the new value.
Since Kotlin
2.1Samples
import kotlin.concurrent.atomics.*
import kotlin.concurrent.thread
fun main() {
//sampleStart
val a = AtomicLong(7)
// Returns the new value after the addition.
println(a.addAndFetch(10)) // 17
println(a.load()) // 17
//sampleEnd
}
Atomically adds the given value to the current value of this AtomicLong and returns the new value.
Has the same memory effects as java.util.concurrent.atomic.AtomicLong.addAndGet.
Since Kotlin
2.1Samples
import kotlin.concurrent.atomics.*
import kotlin.concurrent.thread
fun main() {
//sampleStart
val a = AtomicLong(7)
// Returns the new value after the addition.
println(a.addAndFetch(10)) // 17
println(a.load()) // 17
//sampleEnd
}
Atomically adds the given value to the current value of this AtomicLong and returns the new value.
Since Kotlin
2.1Samples
import kotlin.concurrent.atomics.*
import kotlin.concurrent.thread
fun main() {
//sampleStart
val a = AtomicLong(7)
// Returns the new value after the addition.
println(a.addAndFetch(10)) // 17
println(a.load()) // 17
//sampleEnd
}
Atomically adds the given value to the current value of this AtomicLong and returns the new value.
Since Kotlin
2.1Samples
import kotlin.concurrent.atomics.*
import kotlin.concurrent.thread
fun main() {
//sampleStart
val a = AtomicLong(7)
// Returns the new value after the addition.
println(a.addAndFetch(10)) // 17
println(a.load()) // 17
//sampleEnd
}
Atomically adds the given value to the current value of this AtomicLong and returns the new value.
Since Kotlin
2.1Samples
import kotlin.concurrent.atomics.*
import kotlin.concurrent.thread
fun main() {
//sampleStart
val a = AtomicLong(7)
// Returns the new value after the addition.
println(a.addAndFetch(10)) // 17
println(a.load()) // 17
//sampleEnd
}