aj-geddes avatar

Concurrency Patterns

This is your reference for implementing thread-safe concurrent code across JavaScript, Python, and simulated Go patterns. It covers promise pools, mutexes, semaphores, worker pools, and async/await coordination with working examples in each language. The promise pool and mutex implementations are solid starting points if you need to limit concurrency or prevent race conditions. Most useful when you're building systems that do parallel processing or need to coordinate multiple async operations without hammering resources. The guides are implementation-focused rather than theory-heavy, which means you can copy and adapt quickly. Just remember that concurrent code needs real testing under load, not just unit tests.

skills.sh installs
476
GitHub stars
379
last updated
Aug 21, 2026

Install

$ npx -y skills add aj-geddes/useful-ai-prompts --skill concurrency-patterns --agent claude-code

Installs into .claude/skills of the current project.

Files

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--;
    }
  }

Sponsors

Details

Repository
github.com/aj-geddes/useful-ai-prompts
Categories
AI & Agent Building, Debugging, Automation & Workflows
First seen
Jun 3, 2026

More from aj-geddes/useful-ai-prompts

All 258
1aj-geddes avatardjango-applicationaj-geddes/useful-ai-promptsDevelop production-grade Django applications with models, views, ORM queries, authentication, and admin interfaces. Use when building web applications, managing476skills.sh installs
2aj-geddes avatardeployment-automationaj-geddes/useful-ai-promptsAutomate deployments across environments using Helm, Terraform, and ArgoCD. Implement blue-green deployments, canary releases, and rollback strategies.475skills.sh installs
3aj-geddes avatargcp-cloud-functionsaj-geddes/useful-ai-promptsDeploy serverless functions on Google Cloud Platform with triggers, IAM roles, environment variables, and monitoring. Use for event-driven computing on GCP.475skills.sh installs
4brianrwagner avataryoutube-summarizerbrianrwagner/ai-marketing-claude-code-skillsAutomatically fetch YouTube video transcripts, generate structured summaries, and send full transcripts to messaging platforms. Detects YouTube URLs and provide473skills.sh installs
5intellectronica avatarupstash-redis-kvintellectronica/agent-skillsRead and write to Upstash Redis-compatible key-value store via REST API. Use when there is a need to save or retrieve key-value data, use Redis features (cachin473skills.sh installs
6aj-geddes avatarapi-versioning-strategyaj-geddes/useful-ai-promptsImplement API versioning strategies including URL versioning, header versioning, backward compatibility, deprecation strategies, and migration guides. Use when 472skills.sh installs