StackPractices

Tag: concurrency

Browse 37 practical software engineering resources tagged with "concurrency". Discover code recipes, design patterns, documentation templates, and in-depth guides to help you build, deploy, and maintain production-ready solutions involving concurrency. Each resource is written for engineers who ship real systems, with copy-paste examples and practical trade-offs.

Concurrency and Parallelism

Concurrency is about structuring programs to handle multiple tasks making progress, while parallelism is about executing them simultaneously. Both are essential for modern, multi-core, distributed systems.

The resources below cover threads, async/await, actors, locks, queues, race conditions, and backpressure. Each guide explains how to write concurrent code that is correct, observable, and free from common pitfalls.

Every resource includes clear explanations, copy-paste code, and practical warnings. Use them to make informed decisions, avoid production pitfalls, and speed up your delivery. If you are just getting started, read the beginner-friendly articles first; if you are experienced, jump straight to the advanced patterns and architecture guides. New resources are added regularly, so bookmark this page and check back for the latest patterns.

Distributed Locking with Redis and Redlock

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

Master Async Patterns with Promises, Futures, and Coroutines

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

Thread-Safe Collections: Blocking Queues and Concurrent Maps

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

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

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

Coordinate Concurrent Tasks with Communicating

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

Concurrent Patterns with Go Goroutines and Channels

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

Compose Asynchronous Pipelines with Java CompletableFuture

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

Scale Concurrent Applications with Java Virtual Threads

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

Coordinate Shared Access with Locks, Mutexes, and Semaphores

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

Make Concurrent HTTP Requests with Python and aiohttp

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

Concurrent Async Tasks with asyncio.gather and Task Groups

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

asyncio.Semaphore: Limit Concurrent API Calls in Python

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

Parallelize CPU and I/O Work with ThreadPoolExecutor

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

Build Async Systems with Rust Tokio Runtime

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

Manage Concurrent Work with Thread Pools and Executors

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

Prevent Race Conditions in JavaScript Async Code

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

Prevent and Resolve Deadlocks in SQL Transactions

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

Optimistic Locking in Databases

Implement optimistic locking with versioning to prevent lost updates. Examples in SQL, Node.js,...

Run Shell Commands in Parallel with Bash

Execute multiple shell commands concurrently using xargs, GNU parallel, and background jobs.

Bash Parallel Execution

How to run shell commands in parallel with xargs, GNU parallel, and Bash background jobs while...