title: What is the recommended way to wait till the Completable future threads finish
body: <p>I am using <code>CompletableFuture</code> as shown below in the code. But concerning the way I should wait till all runnables finish, I found two ways and I do not know the difference between them and which one is the best practice? They are as follows:</p>
  
  <p><strong>Code</strong>:</p>
  
  <pre><code>this.growSeedFutureList = CompletableFuture.runAsync(new GrowSeedSERun(this.saliencyMat, this.seedXY, this.seedVal), this.growSeedExecutor);
  this.growSeedFutureList = CompletableFuture.runAsync(new GrowSeedNWRun(this.saliencyMat, this.seedXY, this.seedVal), this.growSeedExecutor);
  this.growSeedFutureList = CompletableFuture.runAsync(new GrowSeedNERun(this.saliencyMat, this.seedXY, this.seedVal), this.growSeedExecutor);
  this.growSeedFutureList = CompletableFuture.runAsync(new GrowSeedSWRun(this.saliencyMat, this.seedXY, this.seedVal), this.growSeedExecutor);
  </code></pre>
  
  <p><strong>First approach to wait till all runnables finish</strong>:</p>
  
  <pre><code>this.growSeedExecutor.shutdown();
  this.growSeedExecutor.awaitTermination(1, TimeUnit.DAYS);
  </code></pre>
  
  <p><strong>Second approach to wait till all runnables finish</strong>:</p>
  
  <pre><code>CompletableFuture.allOf(this.growSeedFutureList).join();
  </code></pre>
  
  <p>Please let me know which one is recommended.</p>