https://kotlinlang.org logo
s

Sergey Chikin

02/19/2018, 9:23 AM
There are
newSingleThreadContext
and
newFixedThreadPoolContext
provided by coroutines library out of box, and you can construct your own
CoroutineContext
based on any
ExecutorService
like this:
Copy code
open class BaseCoroutineDispatcher(private val executor: ExecutorService) : CoroutineDispatcher() {
    override fun dispatch(context: CoroutineContext, block: Runnable) {
        executor.execute(block)
    }
}