아래의 글은 라울-게이브리얼 우르마, 마리오 푸스코, 앨런 마이크로프트 저/우정은 역, 『모던 자바 인 액션』,한빛미디어(2019), CH01의 내용을 기반으로 작성하였습니다.

Synchronize & Asynchronize

Sync : blocking call

Async : non-blocking call

Non-blocking : return first, then call back with results when call completed.

 

Java 8 쉬운 병렬처리

Stream.parallel

CompletableFuture

 

Stream Parallel vs CompletableFuture

Stream.parallel

I/O 가 포함되지 않는 계산 중심의 동작을 실행할 때는 스트림 인터페이스가 가장 구현하기 쉬우며 효율적

CompletableFuture

작업이 I/O를 기다리는 작업을 병렬로 실행할 때는 CompletableFuture가 더 많은 유연성을 제공하며 대기/계산의 비율에 적합한 스레드 수를 설정할 수 있다. 특히 스트림의 게으른 특성 때문에 스트림에서 I/O를 언제 처리할지 예측이 어려움

I/O : 파일 RW, DB작업,

 

kwonnam.pe.kr/wiki/java/8/completable_future

 

java:8:completable_future [권남]

 

kwonnam.pe.kr

www.baeldung.com/java-completablefuture

 

Guide To CompletableFuture | Baeldung

Quick and practical guide to Java 8's CompletableFuture.

www.baeldung.com

 

+ Recent posts