Skip to content
Sharp

Java Threading · interview question

Which of the following Java constructs can be used to execute tasks using Virtual Threads?

Multiple choiceMediumchapter-15-curatedpremiumjava-threadingvirtual-threads
Choose one answer
Answer and explanation

Correct answer

B. Executors.newThreadPerTaskExecutor()

Why

Executors.newThreadPerTaskExecutor() is used to create an ExecutorService where each task is executed with a new Virtual Thread, leveraging the benefits of Virtual Threads.

Test yourself on Java Threading

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

Start free test
All Java Threading questions →