Also, if you never use suspending functions, then ...
# coroutines
e
Also, if you never use suspending functions, then there is no reason to use
runAsync2
. However,
runAsync1
is not the best solution, either. For never-suspending code I’d recommend:
Copy code
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() }
  }
}