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.
-
I'm not sure that you should have a thread pool here. Let the JVM and parallel stream figure it out, based on the number of cores it has available. It'll do a better job of optimizing that you will.duffymo– duffymo2016-03-10 01:19:43 +00:00Commented Mar 10, 2016 at 1:19
-
When Java allows you to configure the thread pool used by parallelStream, you'll be able to do both. For now, you have to live with what you're given. It's good enough much of the time, but if you're processing many slow operations, you may want to do it yourself using @c12's original (Java <8) idea.Paul Hicks– Paul Hicks2016-03-10 01:24:07 +00:00Commented Mar 10, 2016 at 1:24
Add a comment
|