It's doing other enqueued work
# coroutines
j
It's doing other enqueued work
r
What about when there isn't any enqueued work (such as a single
delay
)? Does it just do a busy loop? For example, if I do
Copy code
suspend fun main() {
    delay(10_000L)
}
will it just eat the CPU for 10 seconds, or does it
wait
and
notify
the thread?
j
that's an implementation detail. i suspect it parks the thread and wakes it up if any new work is scheduled. Or perhaps if the gap is small enough it does a busy wait or calls
Thread.onSpinWait
đź‘Ť 2
e
r
I'm not entirely sure what parking is. It seems I have much to learn about coroutines.
e
Parking has nothing to do with coroutines. It is just a low level mechanism that “suspends a thread” in OS. You don’t have to know about it if you are using coroutines.
r
Ah, that makes much more sense. Thanks!
l
đź‘Ť 1