100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

Concurrency & Parallelism Concepts Cheat Sheet

Concurrency & Parallelism Concepts Cheat Sheet

Threads, processes, locks, race conditions, and deadlocks explained alongside async/await, goroutines, and channel-based concurrency patterns.

2 PagesAdvancedApr 5, 2026

Key Terms

Core vocabulary for reasoning about concurrent and parallel systems.

  • Concurrency- Structuring a program so multiple tasks can make progress during overlapping time periods, not necessarily simultaneously
  • Parallelism- Executing multiple computations at literally the same instant, typically across multiple CPU cores
  • Race Condition- A bug where the outcome depends on the unpredictable timing or interleaving of concurrent operations on shared state
  • Deadlock- Two or more threads wait forever for locks held by each other, so none of them can proceed
  • Mutex (Lock)- A synchronization primitive that allows only one thread at a time to access a critical section
  • Semaphore- A counter-based primitive that allows up to N concurrent holders of a resource
  • Critical Section- The part of code that touches shared resources and must not run concurrently on more than one thread
  • Context Switch- The CPU saving one thread's state and loading another's, enabling multitasking on a single core
  • Starvation- A thread is perpetually denied the resources it needs because other threads keep getting priority
  • GIL (Global Interpreter Lock)- CPython's lock that allows only one thread to execute Python bytecode at a time, limiting CPU-bound thread parallelism

Threading with a Lock

Protecting shared state from race conditions using a mutex.

python
import threadingcounter = 0lock = threading.Lock()def increment():    global counter    for _ in range(100_000):        with lock:          # acquire on enter, release on exit            counter += 1threads = [threading.Thread(target=increment) for _ in range(4)]for t in threads: t.start()for t in threads: t.join()print(counter)  # 400000, safe because of the lock

Asyncio Concurrency

Running I/O-bound tasks concurrently on a single thread.

python
import asyncioasync def fetch(name, delay):    await asyncio.sleep(delay)   # non-blocking wait    return f"{name} done"async def main():    results = await asyncio.gather(        fetch("A", 1),        fetch("B", 2),        fetch("C", 1),    )    print(results)  # runs concurrently, total time ~2s not 4sasyncio.run(main())

Goroutines & Channels (Go)

Go's lightweight concurrency primitives for message-passing style concurrency.

go
package mainimport (	"fmt"	"sync")func main() {	var wg sync.WaitGroup	results := make(chan int, 3)	for i := 1; i <= 3; i++ {		wg.Add(1)		go func(n int) { // goroutine: lightweight concurrent function			defer wg.Done()			results <- n * n		}(i)	}	go func() {		wg.Wait()		close(results)	}()	for r := range results { // channel: typed pipe between goroutines		fmt.Println(r)	}}
Pro Tip

Prefer message passing (channels, queues) over shared mutable state guarded by locks when you can — it eliminates whole classes of race conditions by design, per Go's 'share memory by communicating' philosophy.

Was this cheat sheet helpful?

Explore Topics

#ConcurrencyParallelismConcepts#ConcurrencyParallelismConceptsCheatSheet#Programming#Advanced#KeyTerms#ThreadingWithALock#AsyncioConcurrency#GoroutinesChannelsGo#Concurrency#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech

Professional Web Designing Services

  • Responsive Websites
  • E-commerce Solutions
  • SEO Friendly Design
  • Fast & Secure
  • Support & Maintenance
Get a Free Quote

Share this Cheat Sheet