Skip to content

Virtual thread

Category: Units of execution · Status: stub · Lessons: chapter 01, Threads

One line: Java's lightweight thread, final in JDK 21: a Thread that the JVM schedules onto a few carrier platform threads, cheap enough to start one per task.

Also called: Project Loom.

How it connects

flowchart LR
  n_green_thread["Green threads and M:N scheduling"]
  n_virtual_thread["Virtual thread"]
  n_virtual_thread -->|is a| n_green_thread
  classDef center stroke-width:3px
  class n_virtual_thread center
  classDef outside stroke-dasharray: 4 3
  class n_green_thread outside

In each language

Go Goroutines, multiplexed onto OS threads ↗, are the same idea
Java Thread.ofVirtual() and Executors.newVirtualThreadPerTaskExecutor()

Where to read more