0Pricing
Java Academy · Lesson

What Are Virtual Threads

Lightweight threads in Java 21.

Welcome to Virtual Threads

Virtual threads arrived as a final feature in Java 21 (JEP 444). They are lightweight threads managed by the JVM rather than the operating system.

The goal is simple: let you write straightforward thread-per-request code while still scaling to millions of concurrent tasks.

The Old Problem

A traditional platform thread maps one-to-one to an OS thread. Each one consumes around a megabyte of stack and is expensive to create.

That means you can only run a few thousand at once. Blocking I/O ties up an entire OS thread while it waits.

All lessons in this course

  1. What Are Virtual Threads
  2. Creating Virtual Threads
  3. Platform vs Virtual Threads
  4. Pitfalls: Pinning and ThreadLocals
← Back to Java Academy