import kotlinx.coroutines.* import kotlinx.coroutines.channels.Channel import kotlin.coroutines.suspendCoroutine fun main() { val channel = Channel() runBlocking(newSingleThreadContext("Sender")) { println("SENDING 2") channel.send(2) delay(2000) println("SENDING 4") channel.send(4) } runBlocking(newSingleThreadContext("listener")) { println("Listening") for (i in channel) { println(i) } } println("Sleeping") Thread.sleep(4000) }