01
Threads
A job moved to a separate unit of execution and waited on to finish, message passing built on the transfer of ownership, which types can cross a boundary written into the type itself, shared state protected with a lock, and the guarantee a lock-free counter gives through memory ordering.
- 01 Thread Creation The course's opening lesson runs the full measurement core: of thirteen units, 5 advanced on their own, 3 when polled, 3 when something else finished; 2 never advanced at all — thread spawning and joining establish this distribution's on-its-own and when-something-else-finishes classes.
- 02 Message Passing with Channels The side waiting for word from a channel advances when something else finishes; the side that builds and sends the word advances on its own. The sent value's ownership moves into the channel and can no longer be used on the sending side.
- 03 Thread Safety in the Type System Whether a value can cross a thread boundary is a condition written into the type: a design that can cross is actually carried across and its record is read, but the type permitting this does not show that a shared computation will give the same result as an independent assumption would.
- 04 Mutex and Read-Write Lock The side holding a mutex advances on its own, the side waiting for it advances when something else finishes; this order is made deterministic with a channel handshake, and the read side of a read-write lock departs from a mutex by allowing more than one reader at the same time.
- 05 Atomic Operations and Memory Ordering A lock-free counter advances without waiting, needing no one; the same total of increments is carried out both with a mutex and with atomic operations, and the two methods give exactly the same result — the difference is not in the result, but in whether a waiting side exists.