๐ WAYPOINT LESSON
Threads & Happens-Before
โญโญ intermediateโณ 13 min read๐ Lesson 94 of 180
start/join semantics, the run() vs start() trap, and the memory edge join() gives deterministic tests.
Threads, Runnables, and what the JVM promises
A Thread runs a Runnable concurrently; start() begins it, join()
waits for completion:
Thread worker = new Thread(() -> System.out.println("work"));
worker.start();
worker.join(); // deterministic again โ everything before join happened-before after
After join() returns, you may read everything the thread wrote โ that
is the happens-before edge you'll use in every deterministic exercise.
The classic beginner bug is calling run() instead of start(): that
executes the Runnable on the current thread โ sequential, no
concurrency at all.
Threads are expensive (each carries ~1MB stack by default); that is why executors exist โ Module-level coverage, Advanced goes deeper.