Created
April 24, 2021 20:07
-
-
Save ferazog/1306ead0260f8e65c69e7e142bc183cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun ejecutarCoroutine() { | |
val jobPadre = GlobalScope.launch { | |
while(isActive) { | |
println("hola desde la coroutine padre") | |
} | |
} | |
GlobalScope.launch(jobPadre) { // Pasando a la coroutine la referencia al job padre | |
while(isActive) { | |
println("hola desde la coroutine hija") | |
} | |
} | |
Thread.sleep(1_000) | |
jobPadre.cancel() // Cancela la coroutine padre e hija | |
println("fin de la app") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment