https://kotlinlang.org logo
#coroutines
Title
# coroutines
e

Eric Ampire [MOD]

06/03/2020, 6:36 PM
Can someone explain me why the compiler has executed the line 24 before starting the coroutine at the line 18 ?
o

octylFractal

06/03/2020, 6:40 PM
the time it takes to go from "scheduling the coroutine" to "next line of code in same method (line 24)" is much smaller than "start and execute a coroutine" however, specifically in this case, line 24 will always execute first, because
runBlocking
is single-threaded, so the code currently executing on the thread must finish/suspend before other code can be executed. as you can see, once
delay
was called, execution switched over to the
launch
👍 3
e

Eric Ampire [MOD]

06/03/2020, 6:54 PM
Okay thanks 🙏
4 Views