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

nerses

10/01/2018, 8:15 PM
repeat(1000) { loadAndCombine() }
will take 1000 seconds
repeat(1000) { launch { loadAndCombine() }}
will take 1 second my question is whether wrapping it with
launch
is the “correct” way of doing this
g

gildor

10/01/2018, 11:37 PM
Correct if you don't need result or operation
n

nerses

10/02/2018, 7:03 AM
great! thanks @gildor, I guess i can use async, await/awaitall if i need results
g

gildor

10/02/2018, 7:04 AM
and if you want to run them in concurrently, yes. Otherwise use withContext or suspend functions without wrappers
3 Views