So I have a list from which I obtain a parallel stream to fill out a map, as follows:
Map map = new HashMap<>();
List
I would guess that if it is possible for the stream to still be processing you could try something like:
List list = new ArrayList<>();
//Putting data from the list into the map
Map map = list.parallelStream()
.collect(Collectors.toMap(
n -> n.getId(),
n -> new TreeNode(n)
));
At least now you have a terminal on the stream. You will use multiple threads possible and the mapping is certainly going to be complete.