Kotlin 2 · Coroutines

Start coroutines

runBlocking bridges regular code to coroutines. launch starts concurrent work and returns a Job.

import kotlinx.coroutines.*

fun main() = runBlocking {
    launch {
        delay(100)
        println("world")
    }
    println("hello")
}

Official Kotlin 2 documentation

More coroutines commands

All coroutines commands · Kotlin 2 cheatsheet

Was this page helpful?