I am executing a parallel stream with n number of elements; however the the forJoin finish before my collection 'records' processes all elements in parallel stream.
Below my code:
//Created my own ForkJoinPool in order to avoid the common pool
final ForkJoinPool forJoinPool = new ForkJoinPool(commonPool.getParallelism() * 2);
final AtomicInteger at = new AtomicInteger();
forJoinPool.execute(() -> records.parallelStream().forEach(
e -> logger.info("Finished:{}, id:{} ", myService.convert(e, at.incrementAndGet()),
at.get())));
Am I missing something in Parallel Stream? I was expecting ForJoinPool to be closed after all elements in forEach(... are executed.
Aucun commentaire:
Enregistrer un commentaire