CompletableFuture를 사용해 비동기 계산을 시작하고 구성하는 방법을 살펴봅니다:
supplyAsync와
runAsync로 작업을 시작하는 법, 처리기
thenApply,
thenAccept,
thenRun의 차이점, 그리고 이들의 비동기 버전
thenApplyAsync/
thenAcceptAsync/
thenRunAsync를 언제 선택할지. 실행 스레드(
ForkJoinPool 또는 여러분의
Executor), 결과 타입(
CompletableFuture<T>,
CompletableFuture<Void>)과 흔한 실수도 다룹니다: 블로킹하는
get()/
join(),
exceptionally/
handle/
whenComplete 없이 처리되지 않은 예외, 그리고
thenRun 내부에서 결과를 사용하려는 시도 등.