1 // This file was automatically generated from channels.md by Knit tool. Do not edit. 2 package kotlinx.coroutines.guide.exampleChannel08 3 4 import kotlinx.coroutines.* 5 import kotlinx.coroutines.channels.* 6 <lambda>null7fun main() = runBlocking<Unit> { 8 val channel = Channel<Int>(4) // create buffered channel 9 val sender = launch { // launch sender coroutine 10 repeat(10) { 11 println("Sending $it") // print before sending each element 12 channel.send(it) // will suspend when buffer is full 13 } 14 } 15 // don't receive anything... just wait.... 16 delay(1000) 17 sender.cancel() // cancel sender coroutine 18 } 19