Coroutines
Structured concurrency for Kotlin.
What is Coroutines
Coroutines let you write asynchronous code that reads like sequential code, using suspend functions.
Install
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")Usage
suspend fun load() = coroutineScope {
val a = async { api.user() }
val b = async { api.orders() }
a.await() to b.await()
}Docs
Official documentation: Coroutines.