elizarov
04/11/2017, 5:24 PMrunAsync2
. However, runAsync1
is not the best solution, either. For never-suspending code I’d recommend:
val pool = Executors.newFixedThreadPool(myOwnConcurrentLevelThatICanTune) // use pool = ForkJoinPool.commonPool() if you don’t really care about tuning
fun runAsync0(task: () -> Unit) {
pool.execute {
try { task() }
catch (e: Exception) { e.printStackTrace() }
}
}