◐ Shell
clean mode source ↗

Virtual threads

Code Comparison

Thread thread = new Thread(() -> {
    System.out.println("hello");
});
thread.start();
thread.join();
Thread.startVirtualThread(() -> {
    IO.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

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.

Related Documentation

Proof