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

Functions

Link copied to clipboard
open fun isRunning(@NonNull task: Runnable): Boolean
open fun isRunning(@NonNull task: String): Boolean
Check if a task is currently running.
Link copied to clipboard
open fun restart(@NonNull task: Runnable)
open fun restart(@NonNull task: String)
Restart a specific task by stopping it and then starting it again.
Link copied to clipboard
open fun start(@NonNull task: Runnable)
open fun start(@NonNull name: String, @NonNull task: Runnable)
Start a new thread with the given task.
Link copied to clipboard
open fun startLoop(@NonNull task: Runnable)
open fun startLoop(@NonNull loopSleepDuration: Measure<Time>, @NonNull task: Runnable)
open fun startLoop(@NonNull name: String, @NonNull task: Runnable)
open fun startLoop(@NonNull name: String, @NonNull loopSleepDuration: Measure<Time>, @NonNull task: Runnable)
Start a new thread with the given infinite loop task.
Link copied to clipboard
open fun stop(@NonNull task: Runnable)
open fun stop(@Nullable 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(@NonNull task: Runnable)
open fun waitFor(@NonNull task: String)
Wait for a specific task to finish running.
open fun waitFor(@NonNull task: Runnable, interrupt: Boolean)
open fun waitFor(@NonNull task: String, interrupt: Boolean)
Wait for a specific task to finish running, with the option to interrupt it.