How to decide whether to use newWorkStealingPool or newFixedThreadPool?

754 views Asked by At

I understand that in Work Stealing Pool each thread has its own queue where as Fixed Thread Pool has a single shared unbounded queue.

But I'm still not clear in deciding which one is better among them in terms of performance. I see that work stealing pool has an advantage because it steals the work from other thread's queue when it is done processing all of its tasks and both of them use a fixed number of threads.

So is work stealing pool always a better choice ?

1

There are 1 answers

0
programming-tips.jp On

The work-stealing thread pool does not support Future.cancel(true). If you need to interrupt the thread (e.g. using Thread.sleep), you need to use the fixed thread pool. If not, it would be better to use the work-stealing thread pool.

Please see also here.