You were close with your original select, you just...
# coroutines
b
You were close with your original select, you just don't need all the state checks.
Copy code
fun main(args: Array<String>) = runBlocking<Unit> {
  val first = async {
    delay(5, TimeUnit.MINUTES)
  }
  val second = async {
    delay(1, TimeUnit.SECONDS)
    throw Exception("ERROR!")
  }

  select<Unit> {
    listOf(first, second).forEach {
      it.onAwait { }
    }
  }
}