Programmer to Concurrency
This path is for programmers who write sequential Python or R and have not worked with threads or locks. It builds a model of concurrency at the systems level, from what a thread is to how a scheduler balances work, and shows why concurrent code is hard and which primitives help.
Concurrency versus Parallelism versus Multithreading. This defines the terms and shows how they relate.
Processes versus Threads. Processes are isolated. Threads share memory. Each has cost and benefit.
Shared Memory. Multiple threads see the same memory, which is the source of both the speed and the bugs.
Race Conditions. When multiple threads touch shared data, timing matters. Uncontrolled timing causes data corruption.
Mutexes. A mutex is a lock. It lets threads take turns accessing shared data. This is the first tool to prevent races.
Atomics. Atomic operations are indivisible from the hardware perspective. They enable efficient low-level coordination.
Thread Pools. Creating threads is expensive. A pool maintains a set of ready workers. Tasks are queued and distributed.
Work Stealing. Load imbalance is a common problem. Work stealing lets idle threads pull tasks from busy ones.
With these primitives you can judge designs such as the apartment model or a forkserver. threaded-r applies them to R with threads inside one process, and sunlight with processes forked from a template.