Spec-Zone.ru › Kotlin 2

plusAssign

kotlin-stdlib/kotlin.concurrent.atomics/plusAssign

Появилось в Kotlin: 2.1

@ExperimentalAtomicApi
operator fun AtomicInt.plusAssign(delta: Int)

Атомарно добавляет указанное значение к текущему значению этого AtomicInt.

Примеры

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

fun main() { 
   //sampleStart 
   val counter = AtomicInt(7)
counter += 10
println(counter.load()) // 17 
   //sampleEnd
}

@ExperimentalAtomicApi
operator fun AtomicLong.plusAssign(delta: Long)

Атомарно добавляет указанное значение к текущему значению этого AtomicLong.

Примеры

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

fun main() { 
   //sampleStart 
   val counter = AtomicLong(7)
counter += 10
println(counter.load()) // 17 
   //sampleEnd
}

© 2010–2026 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.concurrent.atomics/plus-assign.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API