Is this ok to do? ```val pool = Executors.newFixed...
# coroutines
t
Is this ok to do?
Copy code
val pool = Executors.newFixedThreadPool(N)
val dispatcher1 = pool.asCoroutineDispatcher()
val dispatcher2 = pool.asCoroutineDispatcher()
👎 2
🚫 1
The reason is I want 2 different coroutine scopes. One with a pretty nasty CoroutineExceptionHandler and the other normal
I have something like this
Copy code
class AppCoroutineScope : CoroutineScope by CoroutineScope(dispatcher1 + evilCoroutineExceptionHandler) {
I want this too..
Copy code
class NiceAppCoroutineScope : CoroutineScope by CoroutineScope(dispatcher2) {e
sharing the same underlying thread pool
z
You can use the same dispatcher for those, they’ll still be different scopes
t
Awesome.. I thought so. Thanks for confirmin
z
Just to be clear – i would actively avoid creating two dispatchers for this case, since it suggests to readers of your code that they are different somehow and they’re not.
t
Ah.. same dispatcher, varried scopes.
👍 1