AtomicArray
Creates a new AtomicArray if the given type with the given size, where each element is initialized by calling the given init function.
The function init is called for each array element sequentially starting from the first one. It should return the value for an array element given its index.
Since Kotlin
2.1See also
atomicArrayOf
Throws
if the specified size is negative.
Samples
import kotlin.concurrent.atomics.*
import kotlin.concurrent.atomics.AtomicArray
import kotlin.test.assertFailsWith
fun main() {
//sampleStart
val a = AtomicArray(3) { "a$it" }
println(a.toString()) // [a0, a1, a2]
// Size should be non-negative
// AtomicArray(-1) { "$it" } // will fail with RuntimeException
//sampleEnd
}