J.IX · Java 25 practice question

In a web framework that dedicates a thread to each request, application code creates its own virtual threads to run subtasks. How are those virtual threads related to the request-handling thread?

Choose one answer
Check answer and explanation

Correct answer: They are child threads of the request-handling thread

Explanation

Virtual threads created by user code running on the request-handling thread are child threads of that request-handling thread.

Common trap

Even though virtual threads are lightweight, they still have a parent-child relationship with the thread that creates them. Creating a virtual thread does not replace or invert the relationship with the request-handling thread.

Source: JEP 506: Scoped Values — Description
Checked against the cited text on 2026-11-25.

Report an error in this question