How to use executor service in loop for each iteration?

private ExecutorService executorService = Executors.newFixedThreadPool(3); public void myMethod(){ int batchSize = 2; // calling for 3 pages to test for(int i=0;i<3; i++) { int[…

Java – Multi-threaded crawler with ExecutorService

I’m working to make a crawler in Java. I made a single-threaded crawler to visit a single page and fetch all links on that page. Now I want to make it multi-threaded but facing difficulties. In the …

Impossible to make a cached thread pool with a size limit?

It seems to be impossible to make a cached thread pool with a limit to the number of threads that it can create. Here is how static Executors.newCachedThreadPool is implemented in the standard Java …

Executors.newCachedThreadPool() versus Executors.newFixedThreadPool()

newCachedThreadPool() versus newFixedThreadPool() When should I use one or the other? Which strategy is better in terms of resource utilization?