Concurrency

Concurrency and multithreading patterns for SDE-3 / Senior interviews. Many companies expect backend or distributed-systems candidates to discuss thread safety, locks, and classic concurrency problems.

Contents

File
Description

Producer-Consumer (bounded buffer with Condition), Print FooBar Alternately (semaphores), Reader-Writer Lock. Also: deadlock, starvation, mutex vs semaphore, condition variables. Code in Python.

How this fits SDE-3

Quick checklist

  • Producer-Consumer with bounded buffer and signaling.

  • Alternating execution (FooBar) with semaphores or events.

  • Reader-Writer lock (multiple readers, exclusive writer).

  • Deadlock conditions and prevention.

  • Mutex vs semaphore; when to use condition variables.

Last updated