Skip to content

Instantly share code, notes, and snippets.

View gepron1x's full-sized avatar

gepron1x

  • Decalium Network
  • 13:29 (UTC +03:00)
View GitHub Profile

Using CompletableFuture

CompletableFuture is a plain Java class. It represents the result of an asynchronous computation. A future object is something which will become attainable in the future. When the asynchronous computation finishes, the future is completed.

Introduced in Java 8, CompletableFuture implements the older Future and adds support for callbacks, mapping operations, and cleaner awaiting of completion. If you are using Java 9 or later, you can also use delays and timeouts, subclass CompletableFuture to change the default executor, and take advantage of more utility methods.

Callbacks and operations

What are callbacks?