java - When would you want to use two cached thread pools? -


consider example netty tutorial (although it's not example of i've seen):

executor bosspool = executors.newcachedthreadpool(); executor workerpool = executors.newcachedthreadpool(); channelfactory channelfactory = new nioclientsocketchannelfactory(bosspool, workerpool); 

two separate cached thread pools created here. why? can understand purpose of multiple threads pools if of fixed size, cached thread pools not. why want have multiple cached thread pools if can have 1 expands? in fact, wouldn't better have one? because if have 2 different threads submitting tasks, means more idle worker threads utilized.

i'm wondering because i'm writing networking server, , handling udp , tcp connections separately. want dispatch handling tasks thread pool , considering using cached thread pools that. however, don't know if should use 1 or two.

thanks.

the reason can think of have 2 cached thread pools if need operations on pools differently. example, might have 2 classes of tasks , want awaittermination() on 1 of thread-pools handles 1 class of tasks not other. or maybe want shutdownnow() 1 of pools without affecting other pool allow drain. or maybe have different thread factory each of pools -- although not evident in code example.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -