CronScheduler
Scheduler to execute tasks repeatedly. After using it, you should call the shutdown method. If the JVM finishes without calling shutdown, it will be called upon JVM termination.
Parameters
threads
Number of threads used by the thread pool. By default, it is equals to the number of processors.
Samples
import kotlin.test.Test
import java.lang.Thread.sleep
import kotlin.test.assertEquals
fun main() {
//sampleStart
// sample
val cron = CronScheduler()
val times = 1
var count = 0
// Increments the counter by one each second
cron.schedule("0/1 * * * * ?") {
count++
}
sleep((times * 1_000) + 200L)
cron.shutdown()
assertEquals(count, times)
// sample
//sampleEnd
}