Skip to content
_CORE
AI & Agentic Systems Core Information Systems Cloud & Platform Engineering Data Platform & Integration Security & Compliance QA, Testing & Observability IoT, Automation & Robotics Mobile & Digital Banking & Finance Insurance Public Administration Defense & Security Healthcare Energy & Utilities Telco & Media Manufacturing Logistics & E-commerce Retail & Loyalty
References Technologies Blog Know-how Tools
About Collaboration Careers
CS EN DE
Let's talk

Java 21 Virtual Threads

28. 05. 2020 Updated: 24. 03. 2026 1 min read intermediate
This article was published in 2020. Some information may be outdated.

Virtual threads in Java 21 enable millions of concurrent threads without the overhead of platform threads.

Virtual Threads

// Creating a virtual thread Thread.startVirtualThread(() -> { var result = fetchFromDB(); process(result); }); // ExecutorService with virtual threads try (var executor = Executors.newVirtualThreadPerTaskExecutor()) { List> futures = urls.stream() .map(url -> executor.submit(() -> fetch(url))) .toList(); for (var future : futures) { System.out.println(future.get()); } }

Spring Boot Integration

Java 21 Virtual Threads

spring.threads.virtual.enabled=true

All request handlers run on virtual threads!

When to Use

  • I/O-bound operations (HTTP, DB, file)
  • High number of concurrent requests
  • NOT for CPU-bound operations
  • NOT for synchronized blocks (pinning)

Key Takeaway

Virtual threads = millions of concurrent threads. spring.threads.virtual.enabled=true and you’re done. Watch out for synchronized.

javavirtual threadsconcurrency
Share:

CORE SYSTEMS team

We build core systems and AI agents that keep operations running. 15 years of experience with enterprise IT.