Java / Java 21 Virtual Threads Interview questions
What is a virtual thread in Java 21?
A virtual thread is a lightweight thread implementation introduced as a stable feature in Java 21 under JEP 444. Unlike a regular thread, it isn't tied one-to-one to an operating system thread.
The JVM itself manages virtual threads and multiplexes many of them onto a small pool of real OS threads, called carrier threads. Because creating one doesn't require reserving OS resources, an application can run millions of virtual threads concurrently instead of a few thousand.
They implement the same java.lang.Thread API, so existing blocking-style code works without rewriting it into callbacks or reactive pipelines.
More Related questions...