Run IO computations in parallel in Java8 : <p>I'm familiar with functional programming languages, usually in Scala and Javascript. I'm working on a Java8 project and not sure how I am supposed to run through a list/stream of item, and perform some side-effect for each of them in parallel, using a custom thread pool, and return an object on which it's possible to listen for completion (wether it's a success or failure).</p>

<p>Currently I have the following code, it seems to work (I'm using Play framework Promise implementation as return) but it seems not ideal because ForkJoinPool is not meant to be used for IO intensive computations in the first place.</p>

<pre><code>public static F.Promise&lt;Void&gt; performAllItemsBackup(Stream&lt;Item&gt; items) {
    ForkJoinPool pool = new ForkJoinPool(3);
    ForkJoinTask&lt;F.Promise&lt;Void&gt;&gt; result = pool
            .submit(() -&gt; {
                try {
                    items.parallel().forEach(performSingleItemBackup);
                    return F.Promise.&lt;Void&gt;pure(null);
                } catch (Exception e) {
                    return F.Promise.&lt;Void&gt;throwing(e);
                }
            });

    try {
        return result.get();
    } catch (Exception e) {
        throw new RuntimeException("Unable to get result", e);
    }
}
</code></pre>

<p>Can someone give me a more idiomatic implementation of the above function? Ideally not using the ForkJoinPool, using a more standard return type, and most recent Java8 APIs? Not sure what I'm supposed to use between CompletableFuture, CompletionStage, ForkJoinTask...</p>
