1 /* <lambda>null2 * 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 coroutine-context-and-dispatchers.md by Knit tool. Do not edit. 6 package kotlinx.coroutines.guide.exampleContext07 7 8 import kotlinx.coroutines.* 9 10 fun main() = runBlocking<Unit> { 11 // launch a coroutine to process some kind of incoming request 12 val request = launch { 13 repeat(3) { i -> // launch a few children jobs 14 launch { 15 delay((i + 1) * 200L) // variable delay 200ms, 400ms, 600ms 16 println("Coroutine $i is done") 17 } 18 } 19 println("request: I'm done and I don't explicitly join my children that are still active") 20 } 21 request.join() // wait for completion of the request, including all its children 22 println("Now processing of the request is complete") 23 } 24