Skip to content

Instantly share code, notes, and snippets.

@trix0
Created September 12, 2024 09:57
Show Gist options
  • Save trix0/ebb712aa2b9a0dbdedd8ddb3d88d9fd7 to your computer and use it in GitHub Desktop.
Save trix0/ebb712aa2b9a0dbdedd8ddb3d88d9fd7 to your computer and use it in GitHub Desktop.
Kotlin Coroutines & Flows Masterclass, Coroutine basics Assignment #2
GlobalScope.launch {
val cooBird = launch {
while (true){
delay(1000)
println("Coo")
}
}
val cawBird = launch {
while (true){
delay(2000)
println("Caw")
}
}
val chirpBird = launch {
while (true){
delay(3000)
println("Chirp")
}
}
delay(10.seconds)
cooBird.cancel()
cawBird.cancel()
chirpBird.cancel()
println("Canceled")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment