blob: 4758a869fbafe2ada5d6d183a72df8be315d846e [file] [log] [blame]
Roman Elizarovf16fd272017-02-07 11:26:00 +03001/*
Roman Elizarov1f74a2d2018-06-29 19:19:45 +03002 * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
Roman Elizarovf16fd272017-02-07 11:26:00 +03003 */
4
Roman Elizarovb7721cf2017-02-03 19:23:08 +03005// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
Roman Elizarova9687a32018-06-29 17:28:38 +03006package kotlinx.coroutines.experimental.guide.channel01
Roman Elizarovb7721cf2017-02-03 19:23:08 +03007
Roman Elizarov96695782017-10-01 10:48:15 -07008import kotlinx.coroutines.experimental.*
9import kotlinx.coroutines.experimental.channels.*
Roman Elizarovb7721cf2017-02-03 19:23:08 +030010
11fun main(args: Array<String>) = runBlocking<Unit> {
12 val channel = Channel<Int>()
Roman Elizarov66f018c2017-09-29 21:39:03 +030013 launch {
Roman Elizarovb7721cf2017-02-03 19:23:08 +030014 // 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}