storeAt

expect fun storeAt(index: Int, newValue: T)(source)

Atomically stores the new value into the element of this AtomicArray at the given index.

Since Kotlin

2.1

Throws

if the index is out of bounds of this array.

Samples

import kotlin.concurrent.atomics.*
import kotlin.concurrent.atomics.AtomicArray
import kotlin.test.assertFailsWith

fun main() { 
   //sampleStart 
   val a = AtomicArray(arrayOf("aaa", "bbb", "ccc"))
a.storeAt(1, "kkk")
println(a.loadAt(1)) // kkk
println(a.toString()) // [aaa, kkk, ccc] 
   //sampleEnd
}
actual fun storeAt(index: Int, newValue: T)(source)

Atomically stores the new value into the element of this AtomicArray at the given index.

Since Kotlin

2.1

Throws

if the index is out of bounds of this array.

Samples

import kotlin.concurrent.atomics.*
import kotlin.concurrent.atomics.AtomicArray
import kotlin.test.assertFailsWith

fun main() { 
   //sampleStart 
   val a = AtomicArray(arrayOf("aaa", "bbb", "ccc"))
a.storeAt(1, "kkk")
println(a.loadAt(1)) // kkk
println(a.toString()) // [aaa, kkk, ccc] 
   //sampleEnd
}
actual fun storeAt(index: Int, newValue: T)(source)

Atomically stores the new value into the element of this AtomicArray at the given index.

Has the same memory effects as java.util.concurrent.atomic.AtomicReferenceArray.set.

Since Kotlin

2.1

Throws

if the index is out of bounds of this array.

Samples

import kotlin.concurrent.atomics.*
import kotlin.concurrent.atomics.AtomicArray
import kotlin.test.assertFailsWith

fun main() { 
   //sampleStart 
   val a = AtomicArray(arrayOf("aaa", "bbb", "ccc"))
a.storeAt(1, "kkk")
println(a.loadAt(1)) // kkk
println(a.toString()) // [aaa, kkk, ccc] 
   //sampleEnd
}
actual fun storeAt(index: Int, newValue: T)(source)

Atomically stores the new value into the element of this AtomicArray at the given index.

Since Kotlin

2.1

Throws

if the index is out of bounds of this array.

Samples

import kotlin.concurrent.atomics.*
import kotlin.concurrent.atomics.AtomicArray
import kotlin.test.assertFailsWith

fun main() { 
   //sampleStart 
   val a = AtomicArray(arrayOf("aaa", "bbb", "ccc"))
a.storeAt(1, "kkk")
println(a.loadAt(1)) // kkk
println(a.toString()) // [aaa, kkk, ccc] 
   //sampleEnd
}
actual fun storeAt(index: Int, newValue: T)(source)

Atomically stores the new value into the element of this AtomicArray at the given index.

Since Kotlin

2.1

Throws

if the index is out of bounds of this array.

Samples

import kotlin.concurrent.atomics.*
import kotlin.concurrent.atomics.AtomicArray
import kotlin.test.assertFailsWith

fun main() { 
   //sampleStart 
   val a = AtomicArray(arrayOf("aaa", "bbb", "ccc"))
a.storeAt(1, "kkk")
println(a.loadAt(1)) // kkk
println(a.toString()) // [aaa, kkk, ccc] 
   //sampleEnd
}
actual fun storeAt(index: Int, newValue: T)(source)

Atomically stores the new value into the element of this AtomicArray at the given index.

Since Kotlin

2.1

Throws

if the index is out of bounds of this array.

Samples

import kotlin.concurrent.atomics.*
import kotlin.concurrent.atomics.AtomicArray
import kotlin.test.assertFailsWith

fun main() { 
   //sampleStart 
   val a = AtomicArray(arrayOf("aaa", "bbb", "ccc"))
a.storeAt(1, "kkk")
println(a.loadAt(1)) // kkk
println(a.toString()) // [aaa, kkk, ccc] 
   //sampleEnd
}