如何在Kotlin中创建一个线程池

我想在Kotlin创建一个线程池。 我一直在互联网上搜索几个小时,我不能得到一个例子。 任何人都可以提供示例 谢谢。

val executor = Executors.newFixedThreadPool(5) for (i in 0..9) { val worker = Runnable { println("Hello this is thread " + i) } executor.execute(worker) } executor.shutdown() while (!executor.isTerminated) { } println("Finished all threads")