Go to content

Asynchronous programming in Java 8: how to use CompletableFuture by José Paumard

Java 8 saw the introduction of a new API to handle asynchronous patterns. This API is built on two elements: the CompletionStage interface and the CompletableFuture class. This presentation aims to explain how the patterns introduced by this interface and it implementing class are new to the Java platform, and how they fill the gap in the old Future patterns. The different models are precisely presented: how to create complex asynchronous processing pipelines, how to deal with exceptions, how to test such a complex code. Many examples are shown, from the classical question of remote service access to testing asynchronous REST Service. We will show the new patterns introduced to chain asynchronous operations and how to deal with special threads, especialy in GUI environments. We will also describe new ideas in CDI: asynchronous events.

November 9, 2015