← ClaudeAtlas

principle-concurrencylisted

Concurrency principles — race conditions, livelock, backpressure, lock-free primitives, choosing between mutex vs channel vs actor vs semaphore vs CAS. Auto-load when designing concurrent code, fixing a deadlock, choosing a synchronization primitive, or reasoning about goroutine/thread/task lifetimes.
lugassawan/swe-workbench · ★ 2 · DevOps & Infrastructure · score 68
Install: claude install-skill lugassawan/swe-workbench
<!-- preload-canary: SWB-PRELOAD-PRINCIPLE-CONCURRENCY --> # Concurrency Concurrency is a correctness hazard first, a performance tool second. Prove correctness before optimizing. ## Failure Modes **Race condition** — two goroutines/threads read and write shared state without synchronization; result is non-deterministic. **Fix:** mutex, channel, or atomic. **Deadlock** — two or more tasks each hold a lock the other needs; all block forever. **Fix:** consistent lock-acquisition ordering; prefer higher-level primitives. **Livelock** — tasks keep changing state in response to each other but make no progress; common in retry loops that back off identically. **Fix:** add jitter; use backpressure signals. **Starvation** — a low-priority task never gets scheduled because high-priority tasks monopolize a resource. **Fix:** fair queues; priority inheritance; rate limits. **Lost wakeup** — a condition-variable signal fires before the waiter starts waiting; waiter sleeps forever. **Fix:** always check the predicate in a loop; use atomic flags. **ABA problem** — a CAS succeeds because a value returned to A, masking an intervening change. **Fix:** use version tags or hazard pointers; prefer higher-level data structures. ## Structured Concurrency Child task lifetimes must nest inside the parent's lifetime. No orphan goroutines or threads. - When the parent exits, all children are cancelled first. - Errors propagate up — a child error surfaces to the parent, not to a background l