title: CompletableFuture - supply a method that returns bool value to supplyAsync call
body: <p>I am getting back into Java after a long long time so apologies if the question seems stupid. I am trying to use <em>CompletableFuture</em> to create a non-blocking call. I have a method that returns a boolean</p>
  
  <pre><code>public boolean waitOnState(final String targetState, final long waitMs) {
          long begin = System.nanoTime()/1000000;
          synchronized (stateLock) {
              long elapsedMs = 0L;
              logger.debug(this.storeName + "-" + this.getStreamState().toString());
              while (!this.getStreamState().toString().equals(targetState)) {
  
                  if (waitMs &gt; elapsedMs) {
                      long remainingMs = waitMs - elapsedMs;
                      try {
                          logger.debug("Waiting on stream to be in run state in "+remainingMs);
                          stateLock.wait(remainingMs);
                      } catch (final InterruptedException e) {
                          // it is ok: just move on to the next iteration
                      }
                  } else {
                      logger.debug("Cannot transit to target state");
                      return false;
                  }
                  elapsedMs = System.nanoTime()/1000000 - begin;
              }
              logger.debug("State is running - "+this.storeName);
              return true;
          }
      }
  </code></pre>
  
  <p>And i pass this function to completedFuture in this way:</p>
  
  <pre><code>CompletableFuture&lt;Boolean&gt; resultHandle = 
                  CompletableFuture.supplyAsync(this.waitOnState("RUNNING", 100000));
          resultHandle.thenAccept(result -&gt; System.out.println(result));
  </code></pre>
  
  <p>But I get an error <code>The method supplyAsync(Supplier&lt;U&gt;) in the type *CompletableFuture* is not applicable for the arguments (boolean)</code></p>
  
  <p>The error persists even if I change the return type of my function to Boolean or Integer so I am sure I am invoking the <em>CompletableFuture</em> incorrectly</p>