title: CompletableFuture allOf method behavior
body: <p>I have the following piece of java code:</p>
  
  <pre><code>CompletableFuture&lt;String&gt; future1 = CompletableFuture.supplyAsync(() -&gt; {
              try {
                  Thread.sleep(3);
              } catch (InterruptedException e) {
                  throw new IllegalStateException(e);
              }
              return "Result of Future 1";
          });
  
          CompletableFuture&lt;String&gt; future2 = CompletableFuture.supplyAsync(() -&gt; {
              try {
                  Thread.sleep(3);
              } catch (InterruptedException e) {
                  throw new IllegalStateException(e);
              }
              return "Result of Future 2";
          });
  
          CompletableFuture&lt;String&gt; future3 = CompletableFuture.supplyAsync(() -&gt; {
              try {
                  Thread.sleep(3);
              } catch (InterruptedException e) {
                  throw new IllegalStateException(e);
              }
              return "Result of Future 3";
          });
  
          boolean isdone = CompletableFuture.allOf(future1, future2, future3).isDone();
  
          if (isdone) {
              System.out.println("Future result " + future1.get() + " | " + future2.get() + " | " + future3.get());
          } else {
              System.out.println("Futures are not ready");
          }
  </code></pre>
  
  <p>When I run this code it always prints "Futures are not ready". I am using allOf method here which should wait for all the futures to get completed, but the main thread is not waiting here and priniting the else part. Can someone please help me understand what is going wrong here?</p>