Code:
final ForkJoinPool forkJoinPool = new ForkJoinPool(PARALLELISM_NUMBER);
try {
final List<Record> records = getRecrods();
List<List<Record>> partitionRecordLists = Lists.partition(records, BATCH_SIZE);
forkJoinPool.submit(() ->
partitionRecordLists.parallelStream().forEach(this::performSomething)
).join();
} finally {
forkJoinPool.shutdown();
}
I have above code to perform some tasks in parallel. Given that join already makes caller thread wait until completion, wondering if it should be shutdowNow() instead of shutdown() in the finally block.
Note:performSomething only reads from the input list.