IntermediateCoroutines
suspend Function
Call a suspend function from runBlocking.
Dependency required:
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")kotlin
import kotlinx.coroutines.*
suspend fun load(): String {
delay(200)
return "Ready"
}
fun main() = runBlocking {
println(load())
}Output
Ready
Explanation
load() suspends with delay then returns. runBlocking provides the coroutine context.