title: What's the point of using Future without multithreading?
body: <p>I've inherited some code and there is nobody of the original developers left. The code uses heavily <code>CompletableFuture</code>, and it's the first time I use it, so I'm still trying to wrap my head around it. As I understand it, a <code>(Completable)Future</code> is typically used with some multithreading mechanism that will allow us to do some other thing while a time consuming task is executing, and then simply fetch its result via the Future. As in <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html" rel="nofollow noreferrer">the javadoc</a>:</p>
  
  <pre><code>interface ArchiveSearcher { String search(String target); }
  class App {
      ExecutorService executor = ...
      ArchiveSearcher searcher = ...
      void showSearch(final String target) throws InterruptedException {
          Future&lt;String&gt; future = executor.submit(new Callable&lt;String&gt;() {
          public String call() {
              return searcher.search(target);
          }});
          displayOtherThings(); // do other things while searching
          try {
              displayText(future.get()); // use future
          } catch (ExecutionException ex) { cleanup(); return; }
      }
  }
  </code></pre>
  
  <p>However, in this application that I've inherited, the following pattern that doesn't use any multithreading appears a bunch of times:</p>
  
  <pre><code>public Object serve(Object input) throws ExecutionException, InterruptedException {
      CompletableFuture&lt;Object&gt; result = delegate1(input);
      return result.get();
  }
  
  private CompletableFuture&lt;Object&gt; delegate1(Object input) {
      // Do things
      return delegate2(input);
  }
  
  private CompletableFuture&lt;Object&gt; delegate2(Object input) {
      return CompletableFuture.completedFuture(new Object());
  }
  </code></pre>
  
  <p>To me, this is equivalent to:</p>
  
  <pre><code>public Object serve(Object input) {
      Object result = delegate1(input);
      return result;
  }
  
  private Object delegate1(Object input) {
      // Do things
      return delegate2(input);
  }
  
  private Object delegate2(Object input) {
      return new Object();
  }
  </code></pre>
  
  <p>Of course the code is much more complex, and returns <code>exceptionallyCompletedFuture</code> in case of error, but there are is <code>Callable</code>, no <code>Runnable</code>, no <code>Executor</code>, no <code>supplyAsync()</code> no sign of multithreading. What am I missing? What's the point of using a <code>Future</code> in a singled-threaded context?</p>