Use this skill when the user asks about threads or concurrency: starting threads, thread pools, locks/mutex, race conditions, thread-safe code, or choosing between threads / processes / async.
Clarify context: Identify language/runtime (Python, Java, C#, Node.js, Go, etc.) and what they want (I/O-bound vs CPU-bound, parallelism vs concurrency).
Choose the right tool: Prefer the language’s recommended approach (e.g. async in Node/Python for I/O; threads or processes for CPU; see reference/concepts.md).
Give the right level of detail:
GoalPreferAvoidI/O-bound (network, disk)Async (async/await, asyncio, Promise) or thread poolMany blocking threadsCPU-bound (compute)Processes / process pool, or native threads (Java, Go, C#)Many threads in Python (GIL)Shared mutable stateLocks (mutex), thread-safe collections, or avoid sharingNaked shared variablesProducer–consumerQueue (thread-safe)Busy-wait / ad-hoc signalingRun N tasks in parallelThread pool or process poolManually creating N threadsConceptOne-linerRace conditionTwo threads read/write same data without synchronization; fix with lock or immutable design.DeadlockTwo (or more) threads wait for each other’s lock; fix by consistent lock order or timeouts.GIL (Python)Only one thread runs Python bytecode at a time; use processes or C extensions for CPU-bound.
NeedLocationWhen to use threads vs processes vs asyncreference/concepts.mdLocks, queues, thread pool, shared state patternsreference/patterns.mdPython / Java / C# / Node / Go API quick refreference/languages.mdStarter code / templatesassets/
concurrent.futures) example.Add or reference other language templates in assets/ when the user asks for a specific runtime.