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 flow.md by Knit tool. Do not edit. 6 package kotlinx.coroutines.guide.exampleFlow04 7 8 import kotlinx.coroutines.* 9 import kotlinx.coroutines.flow.* 10 11 fun simple(): Flow<Int> = flow { // flow builder 12 for (i in 1..3) { 13 delay(100) // pretend we are doing something useful here 14 emit(i) // emit next value 15 } 16 } 17 <lambda>null18fun main() = runBlocking<Unit> { 19 // Launch a concurrent coroutine to check if the main thread is blocked 20 launch { 21 for (k in 1..3) { 22 println("I'm not blocked $k") 23 delay(100) 24 } 25 } 26 // Collect the flow 27 simple().collect { value -> println(value) } 28 } 29