How it works...

We are using basically two CompletableFuture methods:

  • supplyAsync: This will start an async call to whatever you put inside of it. We put in a lambda call.
  • thenAcceptAsync: Once the async process is done, the returning value will come here. Thanks to lambdas, we can call this returning value as u (and could be whatever we want). Then, we use it to write it down to the asynchronous response.

Get Java EE 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.