J.VI · Java 25 practice question
In a thread-per-request web framework that uses ScopedValue, application code handling a request spawns its own virtual threads to perform parallel subtasks. How are those spawned virtual threads related to the request-handling thread?
Check answer and explanation
Correct answer: They are child threads of the request-handling thread.
Explanation
When user code running inside a request creates its own virtual threads to run subtasks, those virtual threads are child threads of the request-handling thread.
Common trap
Treating them as detached threads with no relationship is tempting if a developer thinks virtual threads are independent pooled workers, whereas JEP 506 specifically describes them as child threads of the request-handling thread. Replacing the request-handling thread is tempting if someone confuses spawning subtasks with thread migration, yet the original request thread remains the parent.
Source: JEP 506: Scoped Values — Description
Checked against the cited text on 2026-11-25.