Skip to content
Sharp

Concurrency basics · interview question

How can you ensure that a CompletableFuture runs on a specific Executor?

Multiple choiceHardchapter-15-curatedpremiumconcurrencycompletablefuture
Choose one answer
Answer and explanation

Correct answer

D. Use.supplyAsync() with the executor.

Why

To run a CompletableFuture on a specific Executor, use.supplyAsync(Supplier, Executor). This allows the task to begin its execution asynchronously using the provided Executor, giving you control over the thread management.

Test yourself on Concurrency basics

A free test with instant, explained results. No account needed.

Start free test
All Concurrency basics questions →