I have a method that I call using Parallel Streams. the call is as follows :
myList.parallelStream().forEach(f -> doWork(f));
This works as is but I now have a need for doWork to return a boolean signifying whether it failed or succeeded in "Doing Work". Is there a simple way to do something like this ?
myList.parallelStream().forEach(f ->
if ( doWork(f) ) {
incrementSuccessCounter;
} else {
incrementFailedCounter;
}
)
The above does not work but i'm wondering if there is an accepted/standard solution to this situation.