exchange
Atomically stores the given new value into this AtomicLong. and returns the old value.
Since Kotlin
2.1Samples
import kotlin.concurrent.atomics.*
import kotlin.concurrent.thread
fun main() {
//sampleStart
val a = AtomicLong(7)
println(a.exchange(10)) // 7
println(a.load()) // 10
//sampleEnd
}
Atomically stores the given new value into this AtomicLong. and returns the old value.
Since Kotlin
2.1Samples
import kotlin.concurrent.atomics.*
import kotlin.concurrent.thread
fun main() {
//sampleStart
val a = AtomicLong(7)
println(a.exchange(10)) // 7
println(a.load()) // 10
//sampleEnd
}
Atomically stores the given new value into this AtomicLong and returns the old value.
Has the same memory effects as java.util.concurrent.atomic.AtomicLong.getAndSet.
Since Kotlin
2.1Samples
import kotlin.concurrent.atomics.*
import kotlin.concurrent.thread
fun main() {
//sampleStart
val a = AtomicLong(7)
println(a.exchange(10)) // 7
println(a.load()) // 10
//sampleEnd
}
Atomically stores the new value into this AtomicLong and returns the old value.
Since Kotlin
2.1Samples
import kotlin.concurrent.atomics.*
import kotlin.concurrent.thread
fun main() {
//sampleStart
val a = AtomicLong(7)
println(a.exchange(10)) // 7
println(a.load()) // 10
//sampleEnd
}
Atomically stores the given new value into this AtomicLong and returns the old value.
Since Kotlin
2.1Samples
import kotlin.concurrent.atomics.*
import kotlin.concurrent.thread
fun main() {
//sampleStart
val a = AtomicLong(7)
println(a.exchange(10)) // 7
println(a.load()) // 10
//sampleEnd
}
Atomically stores the given new value into this AtomicLong and returns the old value.
Since Kotlin
2.1Samples
import kotlin.concurrent.atomics.*
import kotlin.concurrent.thread
fun main() {
//sampleStart
val a = AtomicLong(7)
println(a.exchange(10)) // 7
println(a.load()) // 10
//sampleEnd
}