kotlinx.coroutines icon indicating copy to clipboard operation
kotlinx.coroutines copied to clipboard

docs: fix example for channel, do not assume a single-threaded dispatcher

Open murfel opened this issue 7 months ago • 0 comments
trafficstars

This example illustrating when send suspends works on a single-threaded dispatcher, but is send guaranteed to suspend on a multithreaded dispatcher?

val channel = Channel<Int>()
launch {
    check(channel.receive() == 5)
}
channel.send(5) // suspends until 5 is received

murfel avatar Apr 21 '25 17:04 murfel