Install
openclaw skills install threadProvides guidance and code examples for using threads, synchronization, thread pools, and concurrency patterns across languages.
openclaw skills install threadUse 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.
| Goal | Prefer | Avoid |
|---|---|---|
| I/O-bound (network, disk) | Async (async/await, asyncio, Promise) or thread pool | Many blocking threads |
| CPU-bound (compute) | Processes / process pool, or native threads (Java, Go, C#) | Many threads in Python (GIL) |
| Shared mutable state | Locks (mutex), thread-safe collections, or avoid sharing | Naked shared variables |
| Producer–consumer | Queue (thread-safe) | Busy-wait / ad-hoc signaling |
| Run N tasks in parallel | Thread pool or process pool | Manually creating N threads |
| Concept | One-liner |
|---|---|
| Race condition | Two threads read/write same data without synchronization; fix with lock or immutable design. |
| Deadlock | Two (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. |
| Need | Location |
|---|---|
| When to use threads vs processes vs async | reference/concepts.md |
| Locks, queues, thread pool, shared state patterns | reference/patterns.md |
| Python / Java / C# / Node / Go API quick ref | reference/languages.md |
| Starter code / templates | assets/ |
concurrent.futures) example.Add or reference other language templates in assets/ when the user asks for a specific runtime.