Atomic Long Array
Начиная с Kotlin: 2.1
inline fun AtomicLongArray(size: Int, init: (Int) -> Long): AtomicLongArray
Создаёт новый AtomicLongArray указанного size, инициализируя каждый элемент вызовом заданной функции init.
Функция init вызывается последовательно для каждого элемента массива, начиная с первого. Она должна возвращать значение элемента массива с учётом его индекса.
Исключения
если указанное значение size отрицательное.
Примеры
import kotlin.concurrent.atomics.*
import kotlin.concurrent.atomics.AtomicArray
import kotlin.test.assertFailsWith
fun main() {
//sampleStart
val a = AtomicLongArray(3) { it * 10L }
println(a.toString()) // [0, 10, 20]
//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/-atomic-long-array.html