Last Updated: June 6, 2026
Virtual threads, finalized in Java 21 under Project Loom, are a new kind of thread that the JVM schedules itself instead of asking the operating system to do it. They let a single Java process run hundreds of thousands or even millions of concurrent tasks without crushing the machine. This lesson covers why the old Thread model hits a wall under high concurrency, what a virtual thread actually is, how to create one, how the JVM multiplexes virtual threads onto a small pool of carrier threads, where the "pinning" pitfall comes from, and the few cases where you should pick something else (like a ForkJoinPool) instead.
The setting is an e-commerce server. The shop is doing well. Concurrent customers went from a few hundred to a hundred thousand, and the server that used to keep up on a single laptop now needs a small fleet to handle the load.