Package kotlin.concurrent

Utility functions for concurrent programming.

Functions

fixedRateTimer
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.

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.

getOrSet
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.

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

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

schedule
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.

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

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

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.

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.

scheduleAtFixedRate
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.

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.

thread
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.

timer
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.

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.

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

Wraps the specified action in a TimerTask.

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

Executes the given action under this lock.

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

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