Coroutines Introduction
Coroutines run asynchronous work in a sequential style. launch starts one and suspend functions can pause.
Example
import kotlinx.coroutines.*
fun main() = runBlocking {
val a = async { delay(100); 20 }
val b = async { delay(100); 22 }
println(a.await() + b.await())
}Exercise
Wait for a result.
a.()
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.