title: ListenableFuture callback execution order
body: <p>Guava's <code>ListenableFuture</code> library provides a mechanism for adding callbacks to future tasks. This is done as follows:</p>
  
  <pre><code>ListenableFuture&lt;MyClass&gt; future = myExecutor.submit(myCallable);
  Futures.addCallback(future, new FutureCallback&lt;MyClass&gt;() {
      @Override
      public void onSuccess(@Nullable MyClass myClass) {
        doSomething(myClass);
      }
  
      @Override
      public void onFailure(Throwable t) {
        printWarning(t);
      }}, myCallbackExecutor);
  }
  </code></pre>
  
  <p>You can wait for a <code>ListenableFuture</code> to complete by calling its <code>get</code> function. For instance:</p>
  
  <pre><code>MyClass myClass = future.get();
  </code></pre>
  
  <p>My question is, are all callbacks for a certain future guaranteed to run before the <code>get</code> terminates. I.e. if there is a future with many callbacks on many callback executors registered, will all the callbacks complete before <code>get</code> returns?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>My use case is, I pass a builder around to many classes. Each class populates one field of the builder. I want all fields to be populated asynchronously because each field requires an external query to generate the data for the field. I want the user who calls my <code>asyncPopulateBuilder</code> to receive a <code>Future</code> on which she can call <code>get</code> and be assured that all the fields have been populated. The way I thought to do it is as follows:</p>
  
  <pre><code>final Builder b;
  ListenableFuture&lt;MyClass&gt; future = myExecutor.submit(myCallable);
  Futures.addCallback(future, new FutureCallback&lt;MyClass&gt;() {
    @Override
    public void onSuccess(@Nullable MyClass myClass) {
      b.setMyClass(myClass);
    }
  
    @Override
    public void onFailure(Throwable t) {
      printWarning(t);
    }}, myCallbackExecutor);
  }
  // Do the same thing for all other fields.
  </code></pre>
  
  <p>What is the recommended way to block until all fields are populated in such a case?</p>