title: What happens to CompleteableFuture when it gets neither completed, cancelled nor an exception?
body: <p>... vs using a callback?</p>
  
  <p>First example, with callback</p>
  
  <pre><code>public class NewClass {
  
      public static final ScheduledExecutorService SCHEDULED_EXECUTOR = Executors.newScheduledThreadPool(1);
  
      @FunctionalInterface
      public interface F_CallbackDef {
  
          void callback(String s);
      }
  
      public void a() {
          b((String s) -&gt; {
              System.out.println(s);
          });
      }
  
      public void b(F_CallbackDef callback) {
          SCHEDULED_EXECUTOR.schedule(() -&gt; {
              String s = "string";
              Random random = new Random();
              boolean cond = random.nextBoolean();
              if (cond) {
                  boolean cond2 = random.nextBoolean();
                  if (cond2) {
                     // assume possible uncatched exeption
                  }
                  callback.callback(s);
                  // in every case:
                  // callback just moves out of scope - no problem
              }
          }, 1, TimeUnit.HOURS);
      }
  }
  </code></pre>
  
  <p>Second example, with CompletableFuture</p>
  
  <pre><code>public class NewClass1 {
  
      public static final ScheduledExecutorService SCHEDULED_EXECUTOR = Executors.newScheduledThreadPool(1);
  
      public void a() {
          CompletableFuture&lt;String&gt; cf = b();
          cf.thenAcceptAsync((String s) -&gt; {
              System.out.println(s);
          });
  
          // cf moves out of scope immediatly
          // but also it gets never completed, nor cancelled
      }
  
      CompletableFuture&lt;String&gt; b() {
          CompletableFuture&lt;String&gt; result = new CompletableFuture&lt;&gt;();
          SCHEDULED_EXECUTOR.schedule(() -&gt; {
              String s = "string";
              Random random = new Random();
              boolean cond = random.nextBoolean();
              if (cond) {
                  boolean cond2 = random.nextBoolean();
                  if (cond2) {
                      // assume possible uncatched exception
                  }
                  result.complete(s);
              }
  
              // assume cond = false or cond2 = false
              // this is not about that result.cancel() SHOULD be called, it is a bug if you will
          }, 1, TimeUnit.HOURS);
          return result;
      }
  
  }
  </code></pre>
  
  <p>Question are:</p>
  
  <ul>
  <li>What happens to cf in example 2 / (When) Will it be removed by garbage collection?</li>
  <li>Is there any better way to "translate" example 1 into example 2?</li>
  </ul>
  
  <p>In your answer, please kindly stay sharp to technical arguments and not to preferred/improvable code (because that is not what this question is about), nor is it about that cf.cancel does not get called.</p>