1 /* 2 * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 3 */ 4 5 // This file was automatically generated from channels.md by Knit tool. Do not edit. 6 package kotlinx.coroutines.guide.exampleChannel01 7 8 import kotlinx.coroutines.* 9 import kotlinx.coroutines.channels.* 10 <lambda>null11fun main() = runBlocking { 12 val channel = Channel<Int>() 13 launch { 14 // this might be heavy CPU-consuming computation or async logic, we'll just send five squares 15 for (x in 1..5) channel.send(x * x) 16 } 17 // here we print five received integers: 18 repeat(5) { println(channel.receive()) } 19 println("Done!") 20 } 21