CompletableFuture 与异步任务编排 | JavaSE

本章覆盖:CompletableFuture 的异步结果模型;completedFuture / supplyAsync / runAsync;thenApply、thenAccept、thenRun;thenCompose 与 thenCombine;allOf 与 anyOf;exceptionally、handle、whenComplete;异步任务链中的线程池选择;阻塞 join/get 与非阻塞编排的区别;默认 ForkJoinPool.commonPool 与显式 Executor 的区别;异步链中的异常传播、超时与阻塞边界。

本章知识点

  • CompletableFuture 的异步结果模型
  • completedFuture / supplyAsync / runAsync
  • thenApply、thenAccept、thenRun
  • thenCompose 与 thenCombine
  • allOf 与 anyOf
  • exceptionally、handle、whenComplete
  • 异步任务链中的线程池选择
  • 阻塞 join/get 与非阻塞编排的区别
  • 默认 ForkJoinPool.commonPool 与显式 Executor 的区别
  • 异步链中的异常传播、超时与阻塞边界