What is the best way to implement a result limit when collecting data via Java 8 parallel streams?
objects.parallelStream().forEach((object) -> {
... complex logic here ...
if (allGood) {
someCollection.add(someData);
someMap.putAll(someEntries);
}
}
What is the best way to halt all further processing once the size of 'someCollection' has reached a result limit?