Executorsmedium3-5 years

thenApply vs thenCompose — and which thread runs the callback?

thenApply maps the result with a function returning a value; thenCompose takes a function returning a future and flattens it — map versus flatMap. Using thenApply there yields a nested future. A plain callback runs on the completing thread, or on the calling thread if the stage is already done; the Async variants dispatch to an executor.

The lesson behind it →
More on Executors