Context (CPU State) Switches Shared memory access Race conditions / data race reordered instructions -> memory barriers / atomics thread switch at any time -> locking / atomics Deadlocks 2x lock no unlock nested locks Lock contention threads wait more than they work Starvation cannot acquire a lock Locks Spin lock (while loop) Ticket lock (get number, wait for that) read/write (shared read, exclusive write) Condition Variables (wake threads up) Pooling Manager Thread (one thread idle, bad) Job stealing (let threads steal from others) Shared queue (threads acquire one job at a time)