Package-level declarations

Utility functions for concurrent programming.

Utility functions for concurrent programming.

Utility functions for concurrent programming.

Types

Link copied to clipboard

An Array in which elements are always updated atomically. For additional details about atomicity guarantees for reads and writes see kotlin.concurrent.Volatile.

Since Kotlin 1.9
Link copied to clipboard
class AtomicInt(var value: Int)

An Int value that is always updated atomically. For additional details about atomicity guarantees for reads and writes see kotlin.concurrent.Volatile.

Since Kotlin 1.9
Link copied to clipboard

An IntArray in which elements are always updated atomically. For additional details about atomicity guarantees for reads and writes see kotlin.concurrent.Volatile.

Since Kotlin 1.9
Link copied to clipboard
class AtomicLong(var value: Long)

A Long value that is always updated atomically. For additional details about atomicity guarantees for reads and writes see kotlin.concurrent.Volatile.

Since Kotlin 1.9
Link copied to clipboard

An LongArray in which elements are always updated atomically. For additional details about atomicity guarantees for reads and writes see kotlin.concurrent.Volatile.

Since Kotlin 1.9
Link copied to clipboard
class AtomicNativePtr(var value: NativePtr)

A kotlinx.cinterop.NativePtr value that is always updated atomically. For additional details about atomicity guarantees for reads and writes see kotlin.concurrent.Volatile.

Since Kotlin 1.9
Link copied to clipboard
class AtomicReference<T>(var value: T)

An object reference that is always updated atomically.

Since Kotlin 1.9
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FIELD])
expect annotation class Volatile

Marks the backing field of the annotated var property as volatile, meaning that reads and writes to this field are atomic and writes are always made visible to other threads. If another thread reads the value of this field (e.g. through its accessor), it sees not only that value, but all side effects that led to writing that value.

Since Kotlin 1.9
actual typealias Volatile = kotlin.jvm.Volatile

Marks the JVM backing field of the annotated var property as volatile, meaning that reads and writes to this field are atomic and writes are always made visible to other threads. If another thread reads the value of this field (e.g. through its accessor), it sees not only that value, but all side effects that led to writing that value.

Since Kotlin 1.9
@Target(allowedTargets = [AnnotationTarget.FIELD])
actual annotation class Volatile

Marks the backing field of the annotated var property as volatile, meaning that reads and writes to this field are atomic and writes are always made visible to other threads. If another thread reads the value of this field (e.g. through its accessor), it sees not only that value, but all side effects that led to writing that value.

Since Kotlin 1.9

Functions

Link copied to clipboard
inline fun <T> AtomicArray(size: Int, init: (Int) -> T): AtomicArray<T>

Creates a new AtomicArray of the given size, where each element is initialized by calling the given init function.

Since Kotlin 1.9
Link copied to clipboard

Creates a new AtomicIntArray of the given size, where each element is initialized by calling the given init function.

Since Kotlin 1.9
Link copied to clipboard

Creates a new AtomicLongArray of the given size, where each element is initialized by calling the given init function.

Since Kotlin 1.9
Link copied to clipboard
inline fun fixedRateTimer(name: String? = null, daemon: Boolean = false, startAt: Date, period: Long, crossinline action: TimerTask.() -> Unit): Timer

Creates a timer that executes the specified action periodically, starting at the specified startAt date and with the interval of period milliseconds between the start of the previous task and the start of the next one.

Since Kotlin 1.0
inline fun fixedRateTimer(name: String? = null, daemon: Boolean = false, initialDelay: Long = 0.toLong(), period: Long, crossinline action: TimerTask.() -> Unit): Timer

Creates a timer that executes the specified action periodically, starting after the specified initialDelay (expressed in milliseconds) and with the interval of period milliseconds between the start of the previous task and the start of the next one.

Since Kotlin 1.0
Link copied to clipboard
inline fun <T : Any> ThreadLocal<T>.getOrSet(default: () -> T): T

Gets the value in the current thread's copy of this thread-local variable or replaces the value with the result of calling default function in case if that value was null.

Since Kotlin 1.0
Link copied to clipboard
inline fun <T> ReentrantReadWriteLock.read(action: () -> T): T

Executes the given action under the read lock of this lock.

Since Kotlin 1.0
Link copied to clipboard
inline fun Timer.schedule(time: Date, crossinline action: TimerTask.() -> Unit): TimerTask

Schedules an action to be executed at the specified time.

Since Kotlin 1.0
inline fun Timer.schedule(delay: Long, crossinline action: TimerTask.() -> Unit): TimerTask

Schedules an action to be executed after the specified delay (expressed in milliseconds).

Since Kotlin 1.0
inline fun Timer.schedule(time: Date, period: Long, crossinline action: TimerTask.() -> Unit): TimerTask

Schedules an action to be executed periodically, starting at the specified time and with the interval of period milliseconds between the end of the previous task and the start of the next one.

Since Kotlin 1.0
inline fun Timer.schedule(delay: Long, period: Long, crossinline action: TimerTask.() -> Unit): TimerTask

Schedules an action to be executed periodically, starting after the specified delay (expressed in milliseconds) and with the interval of period milliseconds between the end of the previous task and the start of the next one.

Since Kotlin 1.0
Link copied to clipboard
inline fun Timer.scheduleAtFixedRate(time: Date, period: Long, crossinline action: TimerTask.() -> Unit): TimerTask

Schedules an action to be executed periodically, starting at the specified time and with the interval of period milliseconds between the start of the previous task and the start of the next one.

Since Kotlin 1.0
inline fun Timer.scheduleAtFixedRate(delay: Long, period: Long, crossinline action: TimerTask.() -> Unit): TimerTask

Schedules an action to be executed periodically, starting after the specified delay (expressed in milliseconds) and with the interval of period milliseconds between the start of the previous task and the start of the next one.

Since Kotlin 1.0
Link copied to clipboard
fun thread(start: Boolean = true, isDaemon: Boolean = false, contextClassLoader: ClassLoader? = null, name: String? = null, priority: Int = -1, block: () -> Unit): Thread

Creates a thread that runs the specified block of code.

Since Kotlin 1.0
Link copied to clipboard
inline fun timer(name: String? = null, daemon: Boolean = false, startAt: Date, period: Long, crossinline action: TimerTask.() -> Unit): Timer

Creates a timer that executes the specified action periodically, starting at the specified startAt date and with the interval of period milliseconds between the end of the previous task and the start of the next one.

Since Kotlin 1.0
inline fun timer(name: String? = null, daemon: Boolean = false, initialDelay: Long = 0.toLong(), period: Long, crossinline action: TimerTask.() -> Unit): Timer

Creates a timer that executes the specified action periodically, starting after the specified initialDelay (expressed in milliseconds) and with the interval of period milliseconds between the end of the previous task and the start of the next one.

Since Kotlin 1.0
Link copied to clipboard
inline fun timerTask(crossinline action: TimerTask.() -> Unit): TimerTask

Wraps the specified action in a TimerTask.

Since Kotlin 1.0
Link copied to clipboard
inline fun <T> Lock.withLock(action: () -> T): T

Executes the given action under this lock.

Since Kotlin 1.0
Link copied to clipboard
inline fun <T> ReentrantReadWriteLock.write(action: () -> T): T

Executes the given action under the write lock of this lock.

Since Kotlin 1.0