Skip to content

Instantly share code, notes, and snippets.

@erdemtopak
Created March 18, 2020 09:33
Show Gist options
  • Save erdemtopak/4e7690c05ed8213edfcdad06ff628532 to your computer and use it in GitHub Desktop.
Save erdemtopak/4e7690c05ed8213edfcdad06ff628532 to your computer and use it in GitHub Desktop.
Coroutine Execution For Humans
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
object Main {
@JvmStatic
fun main(args: Array<String>) {
runBlocking {
val job = launch {
println("Coroutine start")
launch {
println("Child coroutine start")
launch {
println("Child-inner coroutine start")
println("Child-inner coroutine end")
}
println("Child coroutine end")
}
println("Coroutine end!")
}
println("Join")
println("Done")
}
}
}
/*
Output:
Join
Done
Coroutine start
Coroutine end!
Child coroutine start
Child coroutine end
Child-inner coroutine start
Child-inner coroutine end
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment