Virtual threads
Create millions of lightweight virtual threads instead of heavy OS threads.
Code Comparison
✕ Java 8
Thread thread = new Thread(() -> {
System.out.println("hello");
});
thread.start();
thread.join();
✓ Java 21+
Thread.startVirtualThread(() -> {
System.out.println("hello");
}).join();
Why the modern way wins
Lightweight
Virtual threads use KB of memory, platform threads use MB.
Scalable
Create millions of threads — no pool sizing needed.
Simple model
Write blocking code that scales like async code.
Old Approach
Platform Threads
Modern Approach
Virtual Threads
Since JDK
21
Difficulty
beginner
JDK Support
Virtual threads
Available
Widely available since JDK 21 LTS (Sept 2023)
How it works
Virtual threads are lightweight threads managed by the JVM, not the OS. You can create millions of them without tuning thread pools. They're ideal for I/O-bound tasks like HTTP calls and database queries.