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 taskT(): Job { | |
return GlobalScope.launch(Dispatchers.IO) { | |
println("Starting C on ${Thread.currentThread().name}\n") | |
/* | |
* Next we need to do task 'T1' which is a network call. So we call t1() | |
* | |
* suspension: Since t1() is marked suspend, it'll suspend | |
* the calling function. But since the code of 't1' isn't | |
* launching a new coroutine, the same coroutine will be | |
* used to execute t1(). Meaning we continue as if it's | |
* just a synchronous function and the calling function | |
* isn't executing any further i.e. only when t1 returns | |
* with the result will T execute any further. | |
* Task name: T1 | |
* Coroutine name: C1 which is just C | |
* Thread pool: Still IO as we are on 'C' | |
* | |
* We make the network call and then return the result. | |
* */ | |
val resultT1 = t1() | |
// Further code omitted | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment