Skip to content

Instantly share code, notes, and snippets.

@jaozinfs
Created June 7, 2022 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaozinfs/d1973aa76fa0d9f1b7b981adc7d983b3 to your computer and use it in GitHub Desktop.
Save jaozinfs/d1973aa76fa0d9f1b7b981adc7d983b3 to your computer and use it in GitHub Desktop.
fun main() = runBlocking {
val job = launch {
updateUi()...
coroutineScope {
launch {
downloadImage()
}
launch {
downloadSounds()
}
}
println("finish downloads")
updateUi()...
}
job.join()
println("Finish Job")
}
suspend fun downloadImage(){
(1..2).onEach {
delay(300)
println("image $it")
}
}
suspend fun downloadSounds() {
(1..2).onEach {
delay(300)
println("sound $it")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment