Virtual Threads in Java 21 and Java 25 – A Major Evolution in Java Concurrency For many years, Java handled concurrency using traditional platform threads. These threads directly map to operating system threads and are created using the Thread class or through thread pools such as ExecutorService. While platform threads work well, they come with limitations. Each thread requires significant memory for its stack, often around 1 MB. When an application needs to handle thousands of concurrent tasks, this memory overhead becomes a major challenge. In addition, operating systems cannot efficiently schedule very large numbers of threads because of context switching overhead. To address these limitations, Project Loom introduced Virtual Threads. This feature became stable in Java 21 and continues to evolve in later releases like Java 25. Virtual threads are lightweight threads managed by the JVM instead of the operating system. This allows applications to create thousands or even millions of concurrent tasks without exhausting system resources. Example of creating a virtual thread: Thread.startVirtualThread(() -> { // task }); Another common approach is using a virtual thread executor: ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor(); Unlike platform threads, virtual threads do not map one-to-one with OS threads. Instead, many virtual threads run on a small number of platform threads called carrier threads. When a virtual thread performs a blocking operation such as a database call or HTTP request, the JVM suspends the virtual thread and releases the carrier thread to execute another task. This makes blocking operations much more efficient. Platform Threads Managed by the operating system Higher memory usage Limited scalability for massive concurrency Require thread pools for control Virtual Threads Managed by the JVM Very small memory footprint Can scale to hundreds of thousands of threads Simplify concurrent programming Virtual threads are especially useful for IO-heavy systems such as web servers, microservices, and applications that perform many database or network calls. Modern frameworks like Spring Boot are already adding support for virtual threads, making it easier to build highly scalable services with simpler code. Virtual threads represent one of the biggest improvements to Java concurrency in recent years and will likely shape how high-concurrency backend systems are built in the future. #Java #Java21 #Java25 #VirtualThreads #ProjectLoom #SpringBoot #BackendDevelopment #Microservices
Java Virtual Threads in Java 21 and 25 Improve Concurrency
More Relevant Posts
-
Hey Java Developers are you aware of java 25 features! 🚀 Understanding Virtual Threads in Java (Simple Explanation) Recently explored one of the most powerful features in modern Java — Virtual Threads 🧵 👉 Earlier: In traditional Java, each thread was mapped to an OS thread (1:1). So if we created 10 threads → 10 OS threads. This made threads: ❌ Heavy (memory usage) ❌ Expensive (context switching) ❌ Limited in scalability That’s why we used thread pools like: Executors.newFixedThreadPool(10) 👉 Now (Virtual Threads): Java introduces lightweight threads managed by JVM instead of OS. ✔️ Many virtual threads run on a small number of OS threads ✔️ No need to manually limit thread count ✔️ Better scalability for high-concurrency applications Example: Executors.newVirtualThreadPerTaskExecutor() 💡 In short: Old model → 1:1 (Java thread : OS thread) New model → Many : Few (Virtual threads : OS threads) 🔥 Where it helps? Microservices API calls Database operations High concurrent systems This is a game changer for backend developers working with scalable systems. #Java #SpringBoot #Microservices #BackendDevelopment #VirtualThreads #Concurrency #SoftwareEngineering #NewFeatures
To view or add a comment, sign in
-
Java 26 has arrived, bringing several important updates that strengthen the platform's foundation. Hanno Embregts 🎤 🎸 breaks down what's new in this release, including previews and incubators that give us a glimpse of what's coming next. From Project #Leyden 's ahead-of-time compilation improvements to enhancements in the Module System and Vector API updates, this release sets the stage for future #Java development. Whether you're already planning your migration or just want to stay current with the Java ecosystem, this article covers what you need to know. Read the full article: https://lnkd.in/e73S997y #Java #Java26 #OpenJDK #SoftwareDevelopment
To view or add a comment, sign in
-
In Java versions below 24 virtual threads can pin their carrier platform threads during synchronized blocks or native calls. This prevents the carrier from executing other tasks leading to thread starvation and sub-optimal resource usage. Interesting article on differences between Java 21 and Java 24 in terms how they handle virtual thread pinning. https://lnkd.in/dPpsDYHH
To view or add a comment, sign in
-
Discover the remarkable evolution of Java from boilerplate code to a modern powerhouse. From lambdas to records, and virtual threads to efficient I/O work, Java 25 is a far cry from its verbose past. Read how Java 25 is revolutionizing software engineering: https://lnkd.in/gfjERgWr #Java #ModernJava #Java25 #LanguageFeatures #SoftwareEngineering
To view or add a comment, sign in
-
I upgraded the dmx-fun library to Java 25. I thought it was important to write a blog post explaining why it's important for you to update as well, if possible. https://lnkd.in/g7i565qp
To view or add a comment, sign in
-
Java 26 quietly fixed something that always felt… off. Pattern matching has been evolving for years — instanceof, switch, records — but primitives were always left out. Until now. In this new post, I break down how pattern matching for primitive types works, why it matters, and where it actually improves real-world code (beyond the hype). No fluff. Just practical insight 👇 🔗 https://lnkd.in/dCBx4-tj If you’re working with modern Java, this is one of those features that looks small — but makes your code noticeably cleaner. Curious to hear your take: Would you use this in production, or is it just a nice-to-have? #Java #Java26 #SoftwareEngineering #Backend #Programming #CleanCode #JVM
To view or add a comment, sign in
-
☕🚀 Java 21 - A New Era of Modern Java Java continues to evolve, and Java 21 (LTS) brings some powerful features that can truly change the way we write and design applications 💡 From pattern matching to virtual threads, this version pushes Java toward more readable, scalable, and high-performance code 👇 📘 What You Will Learn 🧩 Deconstructing Record Patterns Write cleaner and more expressive code when working with records 🔀 Pattern Matching for Switch More powerful and concise switch statements 📚 Sequenced Collections A new way to work with ordered collections: • Lists, Sets, and Maps with predictable iteration 🔁 🧵 Virtual Threads (Project Loom) A game changer for concurrency 🚀 • Creating and running virtual threads • Using them with CompletableFuture • Virtual thread pools • Custom ThreadFactory • Performance comparison with traditional threads ⚙️ ProcessBuilder & Runtime.exec Interact with the operating system directly: • Execute shell commands • Manage IO streams • Configure environment variables • Build process pipelines Java 21 is not just an upgrade - it’s a shift toward simpler concurrency and more expressive code 🔥 👉 Check the link of the full article in my comment below. #Java #Java21 #JavaDeveloper #VirtualThreads #ProjectLoom #Concurrency #SoftwareEngineering #BackendDevelopment #Programming #TechBlog #LearnJava #DevCommunity
To view or add a comment, sign in
-
-
Exploring the Heart of Java: OpenJDK Core Libraries The OpenJDK Core Libraries Group is responsible for developing and maintaining some of the most essential parts of the Java platform, used by millions of developers worldwide. 💡 These libraries form the backbone of the Java Development Kit (JDK), powering everything from simple applications to large-scale enterprise systems. 💡 Key Feature Areas: ❇️ Language Fundamentals Core classes like java.lang (e.g., String, Object, Math) that every Java program relies on. ❇️ Collections Framework Powerful data structures (List, Set, Map) from java.util for efficient data handling. ❇️ Concurrency & Multithreading High-level APIs in java.util.concurrent for building scalable and thread-safe applications. ❇️ I/O and NIO File handling, buffering, and high-performance non-blocking I/O operations. ❇️ Streams & Functional Programming Stream API for processing collections with a functional style (filter, map, reduce). ❇️ Date & Time API Modern and robust time handling with java.time (introduced in Java 8). ❇️ Reflection & Annotations Dynamic inspection and runtime behavior customization. ❇️ Internationalization (i18n) Support for multiple languages, locales, and formatting. In simple terms, if you are writing Java, you are already leveraging the power of these core libraries every day! Kudos to the amazing contributors who continuously evolve these APIs, ensuring Java remains modern, performant, and developer-friendly. https://lnkd.in/gPhty-Pm #Java #OpenJDK #CoreLibraries #Programming #SoftwareEngineering #Developers
To view or add a comment, sign in
-
Modern Java quietly made the Visitor pattern relevant again. Sealed classes changed the tradeoffs. It might be time to revisit Visitor. I wrote about why Visitor still makes sense if you're using Java 17–20: https://lnkd.in/dPkpgqtb
To view or add a comment, sign in
-
🚀 Java Evolution: The Road to Java 26 Java isn't just evolving; it's accelerating. If you're still on Java 8 or 11, you're missing out on a decade of massive performance and developer experience wins. Here is the "Big Picture" from the standard of 2014 to the powerhouse of 2026: 🟢 Java 8 (The Pivot) • Lambdas & Streams: Functional programming became a first-class citizen. • Optional: A cleaner way to handle the 'null' problem. 🔵 Java 11 (The Modern Baseline) • var keyword: Local type inference for cleaner code. • New HTTP Client: Modern, asynchronous, and reactive. 🟣 Java 17 (The Clean Slate) • Sealed Classes & Records: Better data modeling and restricted hierarchies. • Text Blocks: Finally, readable multi-line strings for JSON/SQL. 🟠 Java 21 (The Concurrency Leap) • Virtual Threads (Project Loom): Scalability that rivals Go and Node.js. • Pattern Matching for Switch: Expressive, safe logic. 🔴 Java 25 — LTS (The Efficiency Master) • Compact Object Headers: Significant memory reduction across the JVM. • Flexible Constructor Bodies: Running logic before super(). • Scoped Values: A modern, safe alternative to ThreadLocal. ⚪ Java 26 (The Native & Edge Power) • HTTP/3 Support: Leveraging QUIC for ultra-low latency networking. • AOT Object Caching: Drastically faster startup and warm-up times. • G1 GC Improvements: Higher throughput by reducing synchronization overhead. 💡 The Takeaway: Java 25 is the current LTS (Long-Term Support) gold standard, but Java 26 shows where we are heading—near-instant startup and native-level performance. What version are you running in production? Is 2026 the year you finally move past Java 11? ☕️ #Java #SoftwareEngineering #Java26 #BackendDevelopment #JVM #Coding #ProgrammingLife
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
👍👍