https://kotlinlang.org logo
Title
d

droidrcc

05/26/2018, 5:42 PM
But is not what I was expecting, they should run sequentially… since they are using the same thread
k

karelpeeters

05/26/2018, 5:53 PM
What? No, what would be the point then?
b

bissell

05/26/2018, 6:26 PM
Using a single thread context is useful for sharing state between coroutines without synchronization. If you need the code to run in sequence you can just ... run it in sequence.
o

oleksiyp

05/27/2018, 1:44 PM
You can easily imaging how it works if you divide program on suspension points. All the code in-between is callabacks and you schedule this callbacks to one-threaded executor. So each delay works not as a sleep, but rather, a schedule. Having one thread here doesn't play any role on how it is executed.