I'm trying to identify a class of Java applications that could benefit from use of parallelStream API introduced in Java 8.
I'm aware of the numerous caveats of the API described in other SO posts :
- Shared fork/join pool, with non trivial starting time, and some potential issues with contention in the pool
- Uncontrolled use of system resources in a way that makes using this sort of code on a server (that already has a multi-task policy) might actually be a bad idea
- ... there are other criticisms mostly related to performance
Still, the API offers to make use of modern multicore machines with code that is not very intrusive provided Stream API is already used, so no hassle multi-threading at low development cost. I would therefore still like to think it can be useful in some scenarios.
I'm thinking the application context thus has to be something like :
- my application is currently sequential
- there is a response time issue, in terms of wall clock time, e.g. the user clicked a GUI button and is waiting for reply
- the application is running on client machines, where most of the time we can expect to have some available CPU cores, not on a server where resources are already contended
- my development team does not have the manpower/skills to develop their own task allocation/threading mechanism, so they would not go for parallelism unless they can do it easily using this API
I searched on github, but it's quite hard to find relevant examples of parallelStream usage that are not exercises or textbook examples (I'd welcome links to some usage in midsize+ projects of the API).
So which kind of applications were the Java language developers targetting with this API ?
Would you agree with the above requirements on the application context for the API to be useful ?