Java Virtual Threads Are a Bigger Deal Than You Think
Part of the series “Java 21 & Spring Boot” · part 3 of 5
- Immutability in Java 21: Records, Defensive Copying, and Collections
- Modern Spring Boot with Java 21 — Virtual Threads, ScopedValue, and Structured Concurrency
- Java Virtual Threads Are a Bigger Deal Than You Think
- Spring Boot + JPA + Virtual Threads (Java 21): Avoid N+1, OSIV & Pagination Pitfalls
- The Complete Guide to RestClient in Spring Boot 3.2 with Java 21 Virtual Threads
On this page
A Practical Guide with Pros, Cons, and When to Use Them.
Concurrency has always been one of Java’s strengths — and also one of its pain points.
With Project Loom, Java introduced Virtual Threads, a new concurrency model designed to make highly concurrent applications simpler, faster, and more scalable.
In this article, we’ll cover:
- What Traditional (Platform) Threads are
- What Virtual Threads are and why they exist
- Pros and cons of both
- When to use each (and when not to)

Java Virtual Threads vs. Platform Thread
1. Traditional Threads (Platform Threads)
What are Platform Threads?
Traditional Java threads (now officially called Platform Threads) map one-to-one with operating system threads.
Java Thread → OS Thread → CPU Core
Each request or task typically occupies one OS thread.
How request flow works
- A request arrives
- A platform thread is assigned
- The thread executes the task
- If the thread blocks (I/O, DB call), the OS thread blocks too
Key characteristics
- Heavyweight
- Managed by the OS
- Limited by system resources
- Blocking is expensive
Pros of Platform Threads
✅ Great for CPU-bound tasks
They map directly to CPU cores, so they’re efficient for computation-heavy work.
✅ Mature and battle-tested
Used for decades — predictable behavior, tons of tooling support.
✅ Works well with synchronized blocks & native code
Some low-level or native operations still work best with platform threads.
Cons of Platform Threads
❌ Poor scalability for I/O-heavy workloads
Thousands of concurrent requests = thousands of OS threads = trouble.
❌ High memory cost
Each thread uses ~1MB stack memory (varies by JVM/OS).
❌ Thread exhaustion risk
Thread pools can fill up quickly under load, causing request latency or failures.
When to Use Platform Threads
✔ CPU-intensive processing
✔ Low-concurrency systems
✔ Applications using heavy native code
✔ Real-time or latency-critical workloads
2. Virtual Threads (Java 21+)
What are Virtual Threads?
Virtual Threads are lightweight threads managed by the JVM, not the OS.
They follow a many-to-few model:
Many Virtual Threads
↓
Few Carrier (Platform) Threads
↓
CPU Cores
Why were they introduced?
To solve the “blocking is expensive” problem without forcing developers into reactive programming.
You can write simple, synchronous code — and still scale to millions of concurrent tasks.
How request flow works with Virtual Threads
- A request gets its own virtual thread
- Virtual thread runs on a carrier thread
- If it blocks (I/O, sleep, DB call):
- JVM parks the virtual thread
- Carrier thread is freed
4. When I/O completes, the virtual thread resumes
➡ Blocking becomes cheap
Pros of Virtual Threads
✅ Massive scalability
You can create millions of virtual threads.
✅ Low memory usage
Stack memory grows on demand.
✅ Simple programming model
No callbacks, no reactive chains — just normal code.
✅ Perfect for I/O-heavy workloads
Web servers, microservices, APIs, DB calls.
Cons of Virtual Threads
❌ Not ideal for CPU-bound work
They don’t make CPU faster — CPU cores are still limited.
❌ Not all libraries are fully optimized yet
Older libraries using native blocking may reduce benefits.
❌ Debugging and profiling still evolving
Tooling is improving but not fully mature everywhere.
When to Use Virtual Threads
✔ High-concurrency web applications
✔ REST APIs & GraphQL servers
✔ Microservices
✔ Applications with lots of blocking I/O
✔ Replacing large thread pools safely
Example:
try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
executor.submit(() -> handleRequest());
}
When NOT to Use Virtual Threads
✖ CPU-heavy batch processing
✖ Tight real-time constraints
✖ Code with heavy synchronized blocks
✖ Applications relying heavily on native blocking calls
Virtual Threads vs Platform Threads (Quick Comparison)
| Feature | Platform Threads | Virtual Threads |
| ----------------- | ---------------- | --------------- |
| OS mapping | 1:1 | Many:Few |
| Memory usage | High | Very low |
| Blocking cost | Expensive | Cheap |
| Scalability | Limited | Massive |
| Best for | CPU-bound | I/O-bound |
| Programming style | Synchronous | Synchronous |
Final Thoughts
Virtual Threads are not a replacement for platform threads, but a powerful addition.
Think of it this way:
- Platform Threads → control the CPU
- Virtual Threads → control concurrency
For modern backend systems handling thousands of simultaneous requests, Virtual Threads are a game changer.
They let you write simple Java code while achieving reactive-level scalability — without the complexity.
Thank you!
More Java 21 articles