Skip to content

Instantly share code, notes, and snippets.

@david-romero
Last active December 4, 2018 10:56
Show Gist options
  • Save david-romero/f843d0b2e9e098600db29f3bc25ec563 to your computer and use it in GitHub Desktop.
Save david-romero/f843d0b2e9e098600db29f3bc25ec563 to your computer and use it in GitHub Desktop.
List<CompletableFuture<Void>> futureList = getAllFuture();
CompletableFuture<Void> allFutureTogether = CompletableFuture.allOf(futureList.toArray());
allFutureTogether.whenComplete( (voidObject, error) -> {
if ( error == null ){
// all future ended successfully
List<Correo> copyOfCorreos = new ArrayList<>(procesar);
Correo lastCorreo = getLastSentCorreo(copyOfCorreos);
configuracionCorreoService.save(lastCorreo);
} else {
// some thread has ended with error.... should I send an email with the error?
log.error("OOPPS", error);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment