virtual threads are a new type of lightweight thread introduced to handle high concurrency efficiently. Internally, they work using a continuation-based model, where the JVM can pause and resume the thread as needed.
When a virtual thread performs a blocking operation (like I/O), it doesn’t block the OS thread. Instead, the JVM temporarily unmounts it and uses the underlying thread to run other virtual threads. This allows you to create millions of threads without much overhead.
Virtual threads are managed by the JVM, not the operating system, and they are ideal for scalable applications where traditional thread models become expensive.