galex
07/20/2017, 12:41 PMdiesieben07
07/20/2017, 12:42 PMCommonPool
is a limited thread pool, it is limited based on the number of cores you have. Your second version just spawns a new thread for every URL, so they really all download in parallel. This is both not ideal though, ideally you'd use non-blocking IO for this instead of spawning 111 threads.diesieben07
07/20/2017, 12:43 PMCommonPool
is made for coroutines that mostly "do nothing" for most of the time (i.e. "wait 20 seconds then do this").kirillrakhman
07/20/2017, 12:43 PMkirillrakhman
07/20/2017, 12:44 PMadeln
07/20/2017, 12:46 PMval BLOCKING_IO = Executors.newCachedThreadPool().asCoroutineDispatcher()
kirillrakhman
07/20/2017, 12:46 PMgalex
07/20/2017, 12:47 PMgalex
07/20/2017, 12:47 PMgalex
07/20/2017, 12:49 PMgalex
07/20/2017, 12:51 PMdiesieben07
07/20/2017, 12:51 PMgalex
07/20/2017, 12:53 PMadeln
07/20/2017, 12:54 PMBLOCKING_IO
dispatcher would create 111 threads and cache them for reuse
CommonPool
size is limited by the number of coresadeln
07/20/2017, 12:55 PMCommonPool
with blocking IOgalex
07/20/2017, 12:55 PMgalex
07/20/2017, 12:55 PMkirillrakhman
07/20/2017, 12:56 PMawait
using coroutinesgalex
07/20/2017, 12:56 PMkirillrakhman
07/20/2017, 12:57 PMgalex
07/20/2017, 12:58 PM