Files
java-core-examples/completablefuture/output/01-thenapply-vs-thencompose.txt
T

12 lines
628 B
Plaintext

== 1. thenApply with a function that itself returns a CompletableFuture
nested.join() is a: CompletableFuture
inner.join() is: Order[userId=1, item=laptop]
== 2. thenCompose flattens it
flat.join() is: Order[userId=1, item=laptop]
== 3. Same three tools, measured (fixed pool of 4, so nothing queues)
dependent calls: thenCompose (100 ms then 150 ms) -> Order[userId=1, item=laptop] 251 ms
independent calls: start both, then thenCombine -> ankur + winter-sale 125 ms
independent calls, wrongly chained with thenCompose -> ankur + winter-sale 221 ms