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