StackPractices

concurrency

Practical resources about concurrency for software engineers.

37 results

Managing Parallel Execution

Modern hardware is parallel, but writing correct concurrent code remains one of the hardest problems in software engineering. Race conditions, deadlocks, and thread starvation can cause bugs that only appear under production load.

This collection covers async patterns, thread pools, locks and mutexes, concurrent data structures, and message-passing models like CSP. Each pattern includes common pitfalls and language-specific implementation advice.

advanced

Distributed Locking with Redis and Redlock

Implement distributed locks with Redis for mutual exclusion across processes, using SET NX with TTL...

intermediate

Master Async Patterns with Promises, Futures, and Coroutines

How to write efficient concurrent code using async/await, promises, futures, and coroutines in...

intermediate

Thread-Safe Collections: Blocking Queues and Concurrent Maps

How to safely share collections between threads using concurrent data structures—blocking queues,...

intermediate

Build Async Pipelines with C# async/await and Task.Run

Build async pipelines in C# using async/await, Task.Run, Task.WhenAll, Task.WhenAny,...

intermediate

Coordinate Concurrent Tasks with Communicating

How to structure concurrent programs using channels, select statements, and goroutines for safe...

intermediate

Concurrent Patterns with Go Goroutines and Channels

Build concurrent systems in Go using goroutines, channels, select statements, worker pools,...

advanced

Compose Asynchronous Pipelines with Java CompletableFuture

Build non-blocking async pipelines in Java using CompletableFuture with thenCompose, thenCombine,...

intermediate

Scale Concurrent Applications with Java Virtual Threads

Scale Java applications with virtual threads from Project Loom. Use Thread.ofVirtual,...

java virtual-threads concurrency
intermediate

Coordinate Shared Access with Locks, Mutexes, and Semaphores

How to prevent race conditions in concurrent programs using mutexes, read-write locks, semaphores,...

intermediate

Make Concurrent HTTP Requests with Python and aiohttp

Fetch multiple APIs concurrently using asyncio and aiohttp. Covers connection pooling, rate...

intermediate

Concurrent Async Tasks with asyncio.gather and Task Groups

Execute multiple async operations concurrently in Python using asyncio.gather, asyncio.TaskGroup,...

intermediate

asyncio.Semaphore: Limit Concurrent API Calls in Python

Use asyncio.Semaphore in Python to cap concurrent API calls, database queries, and resource access...

intermediate

APScheduler BackgroundScheduler: Prevent Overlapping Jobs

Run cron-like jobs in Python using APScheduler. Covers interval, cron, and date triggers, job...

intermediate

Parallelize CPU and I/O Work with ThreadPoolExecutor

Use Python's ThreadPoolExecutor for parallel I/O operations, thread-safe result collection, Future...

intermediate

Build Async Systems with Rust Tokio Runtime

Build async systems in Rust using the Tokio runtime with tasks, channels, select, synchronization...

intermediate

Manage Concurrent Work with Thread Pools and Executors

How to efficiently manage worker threads using thread pools, executors, and rejection policies in...

intermediate

Prevent Race Conditions in JavaScript Async Code

Identify and fix race conditions in asynchronous JavaScript using proper sequencing, atomic...

intermediate

Prevent and Resolve Deadlocks in SQL Transactions

Identify deadlock patterns in SQL databases, apply consistent lock ordering, use appropriate...

deadlocks isolation-levels sql concurrency
intermediate

Concurrent HTTP Requests with asyncio.gather and aiohttp

Fetch multiple HTTP endpoints concurrently using asyncio.gather and aiohttp with error handling,...

intermediate

Leader Election Pattern

Coordinate a single active instance among multiple distributed nodes to avoid conflicts and...

No results found.