Showing posts with label Java Virtual Threads. Show all posts
Showing posts with label Java Virtual Threads. Show all posts

Thursday, April 23, 2026

Java Platform Threads Limit: Performance Impact & Cost Guide

Wondering what makes Java applications hard to scale up to thousands of concurrent tasks?

The solution is the cost of platform threads, which are the traditional Java threads. In this blog, we will discuss the behavior of platform threads when loaded, limitations, and why developers are moving to the new virtual threads of Java in order to scale.

Thread related topics

Java Platform Threads are Costly

Java platform threads are costly because of:

  • OS-level memory
  • Context switching
  • Lifecycle costs

Java platform threads are heavyweight operating system threads, which:

  • Use a lot of memory (usually 1MB stack memory)
  • Are costly to create and operate at large scale

The JVM throws errors like:

OutOfMemoryError: unable to create new native thread

What are Platform Threads in Java?

Java has a traditional thread supported by a native operating system thread called a platform thread.

Each thread:

  • Is created with new Thread API
  • Takes dedicated stack memory (1MB by default)
  • Is restricted by OS thread limits

Wednesday, July 23, 2025

Java 21 Virtual Threads Basic and Foundation

Introduction

Hey everyone 👋,

Welcome to the first post in our deep dive series on Java Virtual Threads! Before we jump into the nuts and bolts of virtual threads, it’s important to lay the foundation. Yes, the first couple of sections may feel basic—but they are essential to understand how things work under the hood, especially when we eventually zoom in on virtual threads.

So bear with me. This foundational knowledge will help you fully grasp the power and potential of virtual threads.

🚀 Starting Simple: Running a Java Program

Let’s imagine you’ve developed a simple Java application and packaged it into a JAR file.

 java -jar myapp.jar


When you run this command, your program is loaded into memory and a process is created.

Sunday, July 20, 2025

Ultimate Guide to Java Virtual Threads: Build Scalable Applications with Ease

Are Java Virtual Threads the Future of Concurrency? Absolutely. Here's Why You Should Care.

If you're a Java developer, you already know: every line of code runs on a thread. Threads are the fundamental unit of scheduling and concurrency in any Java application.

Traditionally, developers have relied on multiple OS-level threads to handle concurrent tasks. For example, Spring Boot with embedded Tomcat comes configured with 200 threads by default, allowing it to process up to 200 concurrent requests. Sounds powerful, right?

But here’s the catch...

🧠 Why Traditional Threads Limit Scalability

Each request in a Java web application is processed by a dedicated OS thread. If each request takes 1 second, a 200-thread system can handle 200 requests per second — that’s your application throughput.

So, why not just add more threads?

Because OS threads are heavyweight:

Each thread consumes significant memory.

The OS has limits on how many threads can be created.

Managing thousands of threads leads to context switching overhead, degrading performance.

That’s where Java Virtual Threads come into play — a game-changing concurrency model introduced in Project Loom.

Popular Posts