So let's say we have the following setup:
List<String> strings = Arrays.asList( "lore ipsum ..", ... 10000 strings);
AtomicInteger count = new AtomicInteger(0);
strings.parallelStream().forEach( myString -> {
System.out.println(count.incrementAndGet());
System.out.println(myString);
// ... do more computing
});
Will this code perform considerable faster if I don't use the atomic variable? Is it a good practice to use atomic variables or better try to avoid them if you can?
Other links: Parallel stream - race conditions with atomic variables, Parallel processing