is there a way to configure the thread names used ...
# coroutines
k
is there a way to configure the thread names used by the underlying pools and executors for the coroutine dispatchers provided by stdlib?
g
you could of course make your own
ExecutorService
and then call the extension function
asCoroutineDispatcher()
, that would get you running on threads named whatever you wanted
alternatively you can use CoroutineContext elements
CoroutineName
eg:
Copy code
suspend fun doWork(workItem: WorkItem){
  withContext(CoroutineName("My-API-$workItem") + IOPool){
    //do IO work that your lib offers, or similar
  }
}
k
i'm currently using my own dispatcher from an ExecutorService, but I was looking for a way to use the built in ones now
they seem to be better than just an ExecutorService in some cases
especially the FJP-based default and the IO dispatcher