title: Mongodb async java driver find()
body: <p>I have a webapp in which I have to return the results from a mongodb find() to the front-end from my java back-end.
  I am using the Async Java driver, and the only way I think I have to return the results from mongo is something like this:</p>
  
  <pre><code>public String getDocuments(){
    ...
    collection.find(query).map(Document::toJson)
          .into(new HashSet&lt;String&gt;(), new SingleResultCallback&lt;HashSet&lt;String&gt;&gt;() {
              @Override
              public void onResult(HashSet&lt;String&gt; strings, Throwable throwable) {
                // here I have to get all the Json Documents in the set,
                // make a whole json string and wake the main thread
              }
          });
    // here I have to put the main thread to wait until I get the data in
    // the onResult() method so I can return the string back to the front-end
    ...
    return jsonString;
  }
  </code></pre>
  
  <p>Is this assumption right or there´s another way to do it?</p>