net.dankito.utils.ThreadPool.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-utils Show documentation
Show all versions of java-utils Show documentation
Some basic utils needed in many projects
package net.dankito.utils
import java.util.concurrent.Executors
open class ThreadPool : IThreadPool {
protected val threadPool = Executors.newCachedThreadPool()
override fun runAsync(runnable: () -> Unit) {
threadPool.execute(runnable)
}
override fun shutDown() {
if (threadPool.isShutdown == false) {
threadPool.shutdownNow()
}
}
}