Reputation: 9827
What is the best approach to parallel process a Collection of Java Objects? I would like to have a threadpool of a 100 threads each work on a separate Collection object and perform some action on it. Any ideas? Java 8 is the targeted version.
Upvotes: 1
Views: 304
Reputation: 13999
Use a parallelStream
.
yourCollection
.parallelStream()
.forEach(e -> doStuff(e));
You may also want to collect()
the results afterwards.
Upvotes: 4