thread

fun thread(latch: CountDownLatch, start: Boolean = true, isDaemon: Boolean = false, contextClassLoader: ClassLoader? = null, name: String? = null, priority: Int = -1, block: () -> Unit): Thread

Creates a new thread that automatically counts down the given latch when block completes.

This is a convenience wrapper around kotlin.concurrent.thread that ensures CountDownLatch.countDown is called in a finally block after block finishes.

Return

the created Thread.

Parameters

latch

the CountDownLatch to count down upon completion.

start

whether to start the thread immediately. Defaults to true.

isDaemon

whether the thread is a daemon thread. Defaults to false.

contextClassLoader

the context class loader for the thread, or null.

name

the name of the thread, or null.

priority

the thread priority, or -1 to use the default.

block

the code to execute in the thread.