https://kotlinlang.org logo
#coroutines
Title
# coroutines
c

cy

11/29/2017, 10:02 AM
notice that you will have all 100 coroutines running in parallel, just not concurrently
g

gildor

11/29/2017, 10:15 AM
@Paul Woitaschek Yes, so this example scales not so good. Solution with channel is better:
Copy code
val channel = produce {
        (0..100).forEach {
            send(it)
        }
    }
    (1..3).map {
        async {
            channel.consumeEach {
                println(it)
            }
        }
    }.map {
        it.await()
    }
2 Views