F
F
foonfyrick2021-03-30 06:19:27
Kotlin
foonfyrick, 2021-03-30 06:19:27

Executing coroutines in a thread pool?

Text from the article:
You can execute coroutines on any of your application's thread pools by converting them to a CoroutineDispatcher using the Executor.asCoroutineDispatcher() extension function. Alternatively, you can use the default Dispatchers that come with the coroutine library.

That is, the author says that I can write like that? Or about something else?

val executor = Executors.newFixedThreadPool(3).asCoroutineDispatcher()
val myCoroutine = CoroutineScope(executor).launch {}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2021-03-30
@foonfyrick

Yes, about it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question