Threads

class Threads

Async utilities for running user code on different threads while having control/logging over them.

Author

Lucas Bubner, 2024

Since

1.0.0-pre

See also

Functions

Link copied to clipboard
open fun isRunning(task: Runnable): Boolean
open fun isRunning(task: String): Boolean
Check if a task is currently running.
Link copied to clipboard
open fun restart(task: Runnable)
open fun restart(task: String)
Restart a specific task by stopping it and then starting it again.
Link copied to clipboard
open fun start(task: Runnable)
open fun start(task: Runnable, name: String)
Start a new thread with the given task.
Link copied to clipboard
open fun startLoop(task: Runnable)
open fun startLoop(task: Runnable, name: String)
open fun startLoop(task: Runnable, loopSleepDuration: Measure<Time>)
open fun startLoop(task: Runnable, name: String, loopSleepDuration: Measure<Time>)
Start a new thread with the given infinite loop task.
Link copied to clipboard
open fun stop(task: Runnable)
open fun stop(task: String)
Stop a specific task that is currently running.
Link copied to clipboard
open fun stopAll()
Stop all threads that are currently running.
Link copied to clipboard
open fun waitFor(task: Runnable)
open fun waitFor(task: String)
Wait for a specific task to finish running.
open fun waitFor(task: Runnable, interrupt: Boolean)
open fun waitFor(task: String, interrupt: Boolean)
Wait for a specific task to finish running, with the option to interrupt it.