July 2018
Intermediate to advanced
266 pages
7h 11m
English
As you already know, you can create hundreds or thousands of coroutines, and those can be executed in one or more threads during their life cycle. Some of those coroutines will last for a long time, while others will be short-lived, maybe because they are tied to a temporary task. So, during debugging, it becomes a necessity to identify them.
Consider this simple application:
val pool = newFixedThreadPoolContext(3, "myPool")val ctx = newSingleThreadContext("ctx")val tasks = mutableListOf<Deferred<Unit>>()for (i in 0..5) { val task = async(pool) { println("Processing $i in ${threadName()}") withContext(ctx) { println("Step two of $i happening in thread ${threadName()}") } println("Finishing $i in ${threadName ...
Read now
Unlock full access