fetchAndDecrement
Atomically decrements the current value of this AtomicInt by one and returns the old value.
Since Kotlin
2.1Samples
import kotlin.concurrent.atomics.*
import kotlin.concurrent.thread
fun main() {
//sampleStart
val a = AtomicInt(7)
println(a.fetchAndDecrement()) // 7
println(a.load()) // 6
//sampleEnd
}
Atomically decrements the current value of this AtomicLong by one 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.fetchAndDecrement()) // 7
println(a.load()) // 6
//sampleEnd
}