blob: 734cbf72f68703a4174f7b1338a60d16b451bdd2 [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 Elizarov2f6d7c92017-02-03 15:16:07 +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.context03
Roman Elizarov2f6d7c92017-02-03 15:16:07 +03007
8import kotlinx.coroutines.experimental.*
Roman Elizarov9fe5f462018-02-21 19:05:52 +03009import kotlin.coroutines.experimental.*
Roman Elizarov2f6d7c92017-02-03 15:16:07 +030010
11fun log(msg: String) = println("[${Thread.currentThread().name}] $msg")
12
13fun main(args: Array<String>) = runBlocking<Unit> {
Roman Elizarov43e3af72017-07-21 16:01:31 +030014 val a = async(coroutineContext) {
Roman Elizarov2f6d7c92017-02-03 15:16:07 +030015 log("I'm computing a piece of the answer")
16 6
17 }
Roman Elizarov43e3af72017-07-21 16:01:31 +030018 val b = async(coroutineContext) {
Roman Elizarov2f6d7c92017-02-03 15:16:07 +030019 log("I'm computing another piece of the answer")
20 7
21 }
22 log("The answer is ${a.await() * b.await()}")
23}