liveBook · Manning

Green thread

As explained in Refactoring to Rust

A green thread is a runtime- or language-managed execution unit scheduled internally rather than directly by the operating system.

A green thread is an execution unit created and scheduled by a language or runtime instead of directly by the operating system. The application may run in one operating-system thread while maintaining its own internal threads. section 8.4

Green threads clarify several concurrency distinctions:

  • POSIX threads are managed by the operating system; green threads are managed internally by the application, language, or runtime. section 8.4
  • Concurrency coordinates tasks that may wait, while parallelism uses multiple execution resources to perform work simultaneously. section 8.4
  • Python’s asyncio manages application threads, but Python’s single-process limitations can prevent operating-system threads from producing expected speedups. section 8.4

The crusher analogy

Waiting cans represent concurrent processes, while each crusher represents execution capacity. Adding crushers increases throughput, but the operating system or runtime determines how that capacity is managed. section 8.4

How Refactoring to Rust covers it

How deep it goes
Defines runtime management and contrasts it with POSIX threads, but stops short of implementation internals.
Examples
Uses a crusher analogy and a Python ThreadPoolExecutor example to illustrate execution capacity and throughput.
What it assumes
Assumes basic concurrency vocabulary while distinguishing concurrency, parallelism, and operating-system thread management.
What you can do after
Evaluate whether language-managed threads or operating-system threads fit a concurrency and parallelism problem.
How it connects
Connects green threads with POSIX threads, asyncio, concurrency, parallelism, and operating-system threads.

Also explained in

Compare how 2 books explain green thread →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Refactoring to Rust. The section links point to the parts of the book it draws on.