concurrency-patterns
並行処理における競合状態を防ぎ、効率的なシステムを構築するために、スレッドセーフなコード、mutex、セマフォ、async/awaitパターン、並行データ構造などを実装するSkill。
📜 元の英語説明(参考)
Implement thread-safe code, mutexes, semaphores, async/await patterns, and concurrent data structures. Use when handling parallel operations, race conditions, or building high-performance concurrent systems.
🇯🇵 日本人クリエイター向け解説
並行処理における競合状態を防ぎ、効率的なシステムを構築するために、スレッドセーフなコード、mutex、セマフォ、async/awaitパターン、並行データ構造などを実装するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o concurrency-patterns.zip https://jpskill.com/download/21375.zip && unzip -o concurrency-patterns.zip && rm concurrency-patterns.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/21375.zip -OutFile "$d\concurrency-patterns.zip"; Expand-Archive "$d\concurrency-patterns.zip" -DestinationPath $d -Force; ri "$d\concurrency-patterns.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
concurrency-patterns.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
concurrency-patternsフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 8
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
並行処理パターン
目次
概要
適切な同期プリミティブとパターンを使用して、並列実行のための安全な並行コードを実装します。
使用場面
- マルチスレッドアプリケーション
- 並列データ処理
- 競合状態の防止
- リソースプーリング
- タスクの調整
- 高性能システム
- 非同期操作
- ワーカープール
クイックスタート
最小限の動作例:
class PromisePool {
private queue: Array<() => Promise<any>> = [];
private active = 0;
constructor(private concurrency: number) {}
async add<T>(fn: () => Promise<T>): Promise<T> {
while (this.active >= this.concurrency) {
await this.waitForSlot();
}
this.active++;
try {
return await fn();
} finally {
this.active--;
}
}
private async waitForSlot(): Promise<void> {
return new Promise((resolve) => {
const checkSlot = () => {
if (this.active < this.concurrency) {
resolve();
// ... (完全な実装についてはリファレンスガイドを参照してください)
リファレンスガイド
references/ ディレクトリ内の詳細な実装:
| ガイド | 内容 |
|---|---|
| Promise Pool (TypeScript) | Promise Pool (TypeScript) |
| Mutex and Semaphore (TypeScript) | Mutex and Semaphore (TypeScript) |
| Worker Pool (Node.js) | Worker Pool (Node.js) |
| Python Threading Patterns | Python Threading Patterns |
| Async Patterns (Python asyncio) | Async Patterns (Python asyncio) |
| Go-Style Channels (Simulation) | Go-Style Channels (Simulation) |
ベストプラクティス
✅ 実施すべきこと
- 適切な同期プリミティブを使用する
- リソース枯渇を避けるため、並行処理を制限する
- 並行操作におけるエラーを処理する
- 可能であれば不変データを使用する
- 並行コードを徹底的にテストする
- 並行処理のパフォーマンスをプロファイリングする
- スレッドセーフティの保証を文書化する
❌ 実施すべきでないこと
- 同期なしで可変状態を共有する
- 調整のためにスリープ/ポーリングを使用する
- 無制限のスレッド/ワーカーを作成する
- 競合状態を無視する
- 非同期コードでイベントループをブロックする
- リソースのクリーンアップを忘れる
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Concurrency Patterns
Table of Contents
Overview
Implement safe concurrent code using proper synchronization primitives and patterns for parallel execution.
When to Use
- Multi-threaded applications
- Parallel data processing
- Race condition prevention
- Resource pooling
- Task coordination
- High-performance systems
- Async operations
- Worker pools
Quick Start
Minimal working example:
class PromisePool {
private queue: Array<() => Promise<any>> = [];
private active = 0;
constructor(private concurrency: number) {}
async add<T>(fn: () => Promise<T>): Promise<T> {
while (this.active >= this.concurrency) {
await this.waitForSlot();
}
this.active++;
try {
return await fn();
} finally {
this.active--;
}
}
private async waitForSlot(): Promise<void> {
return new Promise((resolve) => {
const checkSlot = () => {
if (this.active < this.concurrency) {
resolve();
// ... (see reference guides for full implementation)
Reference Guides
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Promise Pool (TypeScript) | Promise Pool (TypeScript) |
| Mutex and Semaphore (TypeScript) | Mutex and Semaphore (TypeScript) |
| Worker Pool (Node.js) | Worker Pool (Node.js) |
| Python Threading Patterns | Python Threading Patterns |
| Async Patterns (Python asyncio) | Async Patterns (Python asyncio) |
| Go-Style Channels (Simulation) | Go-Style Channels (Simulation) |
Best Practices
✅ DO
- Use proper synchronization primitives
- Limit concurrency to avoid resource exhaustion
- Handle errors in concurrent operations
- Use immutable data when possible
- Test concurrent code thoroughly
- Profile concurrent performance
- Document thread-safety guarantees
❌ DON'T
- Share mutable state without synchronization
- Use sleep/polling for coordination
- Create unlimited threads/workers
- Ignore race conditions
- Block event loops in async code
- Forget to clean up resources
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (2,744 bytes)
- 📎 references/async-patterns-python-asyncio.md (2,068 bytes)
- 📎 references/go-style-channels-simulation.md (1,996 bytes)
- 📎 references/mutex-and-semaphore-typescript.md (1,974 bytes)
- 📎 references/promise-pool-typescript.md (1,158 bytes)
- 📎 references/python-threading-patterns.md (2,912 bytes)
- 📎 references/worker-pool-nodejs.md (2,384 bytes)
- 📎 scripts/validate-api.sh (440 bytes)