我反复发现自己编写代码是这样的:
val threadPoolExecutor = Executors.newCachedThreadPool()
val threadPool = threadPool.asCoroutineDispatcher()
我真正需要的只是协程调度程序,所以我可以编写类似的东西
launch(threadPool) { ... }
或者
withContext(threadPool) { ... }
我需要threadPoolExecutor
能够在清理时关闭它。有没有办法使用协程调度程序实例来关闭它?