In the process of migration to Kotlin, the question arose.
We already have some ThreadPools for different reasons.
How to execute coroutine on existed ThreadPool?
For exampe this code :
suspend fun fetchMedia(): Flow<MediaItem> {
return withContext(Dispatchers.IO) {...}
}
How to replace Dispatchers.IO to my own ThreadPoolExecutor ?
You can use Executor ThreadPools calling
asCoroutineDispatcher()
on it, like this: