透過
CompletableFuture 拆解非同步計算的啟動與組合:如何透過
supplyAsync 與
runAsync 啟動任務,處理器
thenApply、
thenAccept、
thenRun 有何差異,以及何時選擇其非同步版本
thenApplyAsync/
thenAcceptAsync/
thenRunAsync。也會談到執行緒(
ForkJoinPool 或你的
Executor)、結果型別(
CompletableFuture<T>、
CompletableFuture<Void>)與常見錯誤:阻塞的
get()/
join()、缺少
exceptionally/
handle/
whenComplete 的錯誤處理,以及嘗試在
thenRun 內使用結果。