timerTask
Wraps the specified action in a TimerTask.
inline fun timerTask(crossinline action: TimerTask.() -> Unit): TimerTask(source)
import java.util.Timer
import java.util.TimerTask
import kotlin.concurrent.timerTask
fun main() {
val timer = Timer()
// Create a TimerTask that prints a message every second
val task: TimerTask = timerTask {
println("Timer tick at ${java.util.Date()}")
}
// Schedule the task: start immediately, repeat every 1000 ms
timer.schedule(task, 0L, 1000L)
}