Michael Paus
10/26/2024, 12:32 PMval ioDispatcher: CoroutineDispatcher = <http://Dispatchers.IO|Dispatchers.IO>
suspend fun doSomething(ioDispatcher: CoroutineDispatcher) {
withContext(ioDispatcher) {
println("With context $ioDispatcher is running on ${getCurrentThreadName()}")
}
}
When I run the test and pass the defined ioDispatcher
to the function doSomething
the print statement results in the following output:
With context <http://Dispatchers.IO|Dispatchers.IO> is running on DefaultDispatcher-worker-5 @coroutine#18
Why is this running on a DefaultDispatcher worker and not on an IODispatcher worker?Alexandru Caraus
10/26/2024, 12:44 PMMichael Paus
10/26/2024, 12:46 PMJoffrey
10/26/2024, 12:47 PMPHondogo
10/26/2024, 12:49 PMPHondogo
10/26/2024, 12:50 PMMichael Paus
10/26/2024, 12:52 PM