I am working on a multithreaded project in which I need to spawn multiple threads to measure the end to end performance of my client code, as I\'m doing Load and Performance
Here is the source of Executors.newFixedThreadPool
:
public static ExecutorService newFixedThreadPool(int nThreads) {
return new ThreadPoolExecutor(nThreads, nThreads,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue());
}
It internally uses ThreadPoolExecutor
class with default configuration as you can see above. Now there are scenarios where default configuration is not suitable say instead of LinkedBlockingQueue
a priority queue needs to be used etc. In such cases caller can directly work on underlying ThreadPoolExecutor
by instantiating it and passing desired configuration to it.