Sobes.tech
Back to tasks
Junior — Senior
52

Коррекция проблем в асинхронном коде

Companies where asked:

IBS
Get help with live coding in real time with Sobes Copilot
Task condition

Требуется обнаружить и устранить некорректное поведение представленного примера на Kotlin.

fun main() = runBlocking {
    async { displaySecond() }
    async { displayFirst() }
}

fun displayFirst() {
    for (idx in 0..10) {
        delay(5)
        println("displayFirst - $idx")
    }
}

fun displaySecond() {
    for (idx in 0..10) {
        delay(10)
        println("displaySecond - $idx")
    }
}