Skip to content

Green threads and M:N scheduling

Category: Units of execution · Status: stub

One line: Threads implemented by a language runtime instead of the operating system, many of them multiplexed onto a smaller number of OS threads.

Also called: user-space threads, M:N threading, lightweight threads.

How it connects

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

In each language

Rust Standard threads are native OS threads ↗; M:N scheduling of tasks comes from an async runtime such as Tokio's ↗
Go Goroutines are M:N: multiplexed onto a set of OS threads ↗
Java Virtual threads ↗ (JDK 21) are scheduled by the Java runtime rather than the operating system
Kotlin Coroutines are sent to threads by dispatchers ↗
Erlang and Elixir Processes are M:N, run by scheduler threads ↗ inside the VM
Haskell forkIO threads are lightweight, scheduled by the GHC runtime rather than the OS

Where to read more