title: CompletableFuture : Invoke a void function asynchronusly
body: <p>I am trying to implement a database query with retry strategy on certain database exceptions. The code for retry strategy is not very relevant, so I did not include it. As you can see in the code below - I have written a retryCallable which takes the retry strategy and the Callable in <code>populateData()</code>.</p>
  
  <p>In <code>getDataFromDB</code>, I get the data from DB and put the data in a global hashmap which serves as a cache at an application level.</p>
  
  <p>This code is working as expected. I would like to invoke <code>populateData</code> from a different class. However, this would be a blocking call. Since this is Database and has retry strategy, this could be slow. I want to call <code>populateData</code> asynchronously.</p>
  
  <p>How can I use CompletableFuture or FutureTask to achieve this? 
  <code>CompletableFuture.runAsync</code> expects a runnable. <code>CompletableFuture.supplyAsync</code> expects a supplier. I have not implemented these things before. So any advice on best practices would be helpful. </p>
  
  <pre><code>Class TestCallableRetry {
  
  public void populateData() {
          final Callable&lt;Set&lt;String&gt;&gt; retryCallable = new RetryingCallable&lt;&gt;(retryStrategyToRetryOnDBException(), getDataFromDB());
          Set&lt;String&gt; data = new HashSet&lt;&gt;();
  
          data = retryCallable.call();
  
          if (data != null &amp;&amp; !data.isEmpty()) {
              // store data in a global hash map
          }
      }
  
      private Callable&lt;Set&lt;Building&gt;&gt; getDataFromDB() {
          return new Callable&lt;Set&lt;String&gt;&gt;() {
              @Override
              public Set&lt;String&gt; call() {
                  // returns data from database
              }
          };
      }
  }
  
  Class InvokeCallableAsynchronously {
      public void putDataInGlobalMap {
        // call populateData asynchronously
      }
  }
  </code></pre>