title: CompletableFuture allof(..).join() vs CompletableFuture.join()
body: <p>I am currently using CompletableFuture supplyAsync() method for submitting some tasks to common thread pool. Here is what code snippet looks like:</p>
  
  <pre><code>final List&lt;CompletableFuture&lt;List&lt;Test&gt;&gt;&gt; completableFutures = resolvers.stream()
          .map(resolver -&gt; supplyAsync(() -&gt; task.doWork()))
          .collect(toList());
  
  CompletableFuture.allOf(completableFutures.toArray(new CompletableFuture[completableFutures.size()])).join();
  
  final List&lt;Test&gt; tests = new ArrayList&lt;&gt;();
  completableFutures.stream()
          .map(completableFuture -&gt; completableFuture.getNow())
          .forEach(tests::addAll);
  </code></pre>
  
  <p>I would like to know how below differs from above code. I removed the parent completableFuture from below code, and added join() for each of the completableFuture instead of getNow():</p>
  
  <pre><code>final List&lt;CompletableFuture&lt;List&lt;Test&gt;&gt;&gt; completableFutures = resolvers.stream()
          .map(resolver -&gt; supplyAsync(() -&gt; task.doWork()))
          .collect(toList());
  
  final List&lt;Test&gt; tests = new ArrayList&lt;&gt;();
  completableFutures.stream()
          .map(completableFuture -&gt; completableFuture.join())
          .forEach(tests::addAll);
  </code></pre>
  
  <p>I am using this in the spring service and there are issues with thread pool exhaustion. Any pointers is deeply appreciated.</p>