Skip to content

Instantly share code, notes, and snippets.

@ferazog
Last active April 24, 2021 14:56
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 ferazog/4a52fbed0d525d273ba1331b2256f09b to your computer and use it in GitHub Desktop.
Save ferazog/4a52fbed0d525d273ba1331b2256f09b to your computer and use it in GitHub Desktop.
Start with coroutines
fun ejecutarCoroutine() {
println("iniciando coroutine")
GlobalScope.launch {
/*
launch es una extensión que permite ejecutar una coroutine,
en este caso dentro del scope GlobalScope
*/
println("hola mundo desde una coroutine")
}
Thread.sleep(1_000) // El sleep permite una brecha de tiempo para que la coroutine termine su trabajo
println("fin de la app")
}
/*
Resultado esperado:
iniciando coroutine
hola mundo desde una coroutine
fin de la app
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment