Card 08/ 08

RecapDifficulty: Advanced1 min

Recap: Threads and What They Cost

start against run, interleaving, one-way states, virtual threads and daemons, with where each was.

Threads come down to the five ideas below, each listed with the card that covers it.

What the topic established, and which card it was on
The ideaWhere
start() creates a thread; run() is an ordinary method callThread.run() vs Thread.start(): Why Calling run() Starts Nothing
Each thread's own order holds; the interleaving between threads does notThread Example: Two Threads Printing at Once
A thread runs once and cannot be restartedThread States: NEW, RUNNABLE, BLOCKED, WAITING and TERMINATED
A virtual thread is scheduled by the virtual machine and costs almost nothingPlatform Threads vs Virtual Threads
The process exits when the last non-daemon thread finishesDaemon Threads: Why a Java Program Does Not Exit

A thread buys overlap and spends ordering. Everything else in this subject is about the consequences of that trade, and none of it shows in code that runs on one thread.