Pihentagy
01/08/2025, 9:34 AMJoffrey
01/08/2025, 11:43 AMPihentagy
01/08/2025, 12:12 PMstreetsofboston
01/08/2025, 12:55 PMJoffrey
01/08/2025, 12:55 PMThreadPoolExecutor
and expose it as a coroutine dispatcher using ExecutorService.asCoroutineDispatcher()
, launching coroutines with this dispatcher will have the same effect (in terms of blocked threads) as launching tasks in the original thread pool executor (assuming the contents of these coroutines is the same blocking code as in the tasks).
On the other hand, launching coroutines instead of submitting runnables to the executor allows you to gradually introduce actual suspending functions in the tasks and benefit from more interlacing.Joffrey
01/08/2025, 12:58 PMtoadzky
01/09/2025, 10:43 PMJoffrey
01/10/2025, 2:12 PMExecutorService
as dispatchers to use it via coroutines