title: Run async actions in sequence
body: <p>I have a sequence of I/O operations (DB, I/O devices...) I need to run in sequence.</p>
  
  <pre><code>@SafeVarargs
  public final CompletableFuture&lt;Boolean&gt; execute(final Supplier&lt;Boolean&gt;... methods)
  {
      CompletableFuture&lt;Boolean&gt; future = null;
  
      for (Supplier&lt;Boolean&gt; method : methods)
      {
          if (future == null)
          {
              future = CompletableFuture.supplyAsync(method, threadPool);
          }
          else
          {
              future.thenCombineAsync(CompletableFuture.supplyAsync(method, threadPool), (result, currentResult) -&gt; result &amp;&amp; currentResult,
                      threadPool);
          }
      }
  
      return future.exceptionally(this::onException);
  }
  </code></pre>
  
  <p>My code executes randomly. </p>
  
  <ol>
  <li>What can I do to ensure order?</li>
  <li>How can I combine results in the end? If all were true, for instance?</li>
  <li>To apply a callback after everything is complete to check the result?</li>
  </ol>