I want to launch a lot of tasks to run on a database of +-42Mio records. I want to run this in batches of 5000 records/time (results in 850 tasks). I also want to limit the
Changed from your code:
ExecutorService executorService = Executors.newFixedThreadPool(16); for (int j = 1; j < 900 + 1; j++) { int start = (j - 1) * 5000; int stop = (j) * 5000 - 1; FetcherRunner runner = new FetcherRunner(routes, start, stop); executorService.submit(runner); }