Junior — Senior
Definition of parallel and sequential execution
livecode
Task condition
Given two functions that call a suspend function. Determine which of them have calls happening simultaneously and which have calls happening one after another.
fun sum(): Int {
val first = async { suspendFun() }.await()
val second = async { suspendFun() }.await()
return first + second
}
fun sum2(): Int {
val first = async { suspendFun() }
val second = async { suspendFun() }
return first.await() + second.await()
}
fun suspendFun(): Int {
longBackgroundWork()
}