Java / Java 21 Virtual Threads Interview questions
Explain the lifecycle of a virtual thread?
A virtual thread moves through the same Thread.State enum as a platform thread, but the transitions are driven by the JVM scheduler rather than the OS.
It starts NEW, becomes RUNNABLE once submitted to the scheduler, transitions to effectively running once mounted onto a carrier, moves to a waiting state whenever it's unmounted for a blocking operation, and finally reaches TERMINATED once its task completes. Unlike a platform thread, the mount/unmount cycle can repeat many times across different carriers during a single virtual thread's life.
More Related questions...