Concurrency Interview Basics for Seniors

Concurrency Interview Basics for Seniors

Concurrency interview basics for seniors are less about naming every Java memory-model clause and more about predictable hazards: races, visibility, deadlock, and how you bound work with pools and timeouts. This talk track keeps you practical in coding pads and design discussions.

What “senior” usually means here

Interviewers expect you to:

They rarely need a textbook dissertation on every fence instruction.

Shared memory: the core hazards

HazardOne-line meaningMitigation sketch
RaceOutcome depends on timing of unsynchronized accessLock, atomic, or confine to one thread
Atomicity surprise“check then act” is not one stepSingle locked critical section / compare-and-swap loop
VisibilityOne thread’s write unseen by anotherProper sync, volatiles/atomics, or message passing
DeadlockCycle of lock acquisitionOrdered locks, try-lock with backoff, fewer locks
StarvationA thread never gets scheduled/resourcesFairness policies; avoid infinite reset of priorities

Talk track:

“The bug class is a check-then-act race on the map; I’ll synchronize the contains-and-put path or use a concurrent structure with the right atomic method.”

Locks vs message passing

Locks / mutexes: good when shared structures are small and critical sections are short. Name what you lock; keep sections tiny.

Atomics / lock-free: fine for counters and flags; do not invent lock-free queues unless that is the prompt.

Message passing / queues: prefer when you can own data per actor and communicate immutable messages—often easier to reason about in design interviews.

Talk track:

“I’d rather pass ownership of the job through a queue than mutate a shared list from many threads.”

Thread pools and bounded work

Unbounded new Thread per request is a senior red flag.

Design sentence:

“CPU-bound workers near core count; blocking I/O gets a larger pool or async I/O, with a bounded queue and clear rejection behavior.”

Deadlock talk track (keep it short)

  1. List the locks
  2. Show acquisition order
  3. Break the cycle (global order) or shrink to one lock
  4. Mention detection only if asked (not your first production plan)

Dining philosophers is a metaphor—map it to your actual resources (DB row locks, connection pools).

Coding-round flavors

Always ask: single process vs distributed? In-memory vs external store? Those answers change tools.

Memory visibility without pedantry

You do not need to lecture happens-before. You do need to say:

“Without synchronization, a reader may see stale fields; the lock that protects writes also publishes those writes to the next locker.”

In languages with volatile / atomics, say you use them for flags and publication, not as a magic race cure for compound actions.

First five minutes in a concurrency design

  1. Actors, data ownership, single-writer where possible
  2. Where mutual exclusion is unavoidable
  3. Pool sizing and queue bounds
  4. Timeouts, cancellation, idempotency under retry
  5. What you will measure (queue depth, p99 latency)

Freeze recovery

  1. Draw two threads and the shared variable
  2. Interleave steps on a timeline until the bug appears
  3. Pick the smallest sync fix
  4. Only then discuss fancy lock-free ideas

Talk track:

“Let me interleave thread A and B on the check-then-act; that shows the race clearly.”

Practice plan

SessionFocus
1Narrate races on a shared map
2Bounded buffer producer/consumer
3Thread-pool + timeout design sketch
4Deadlock order story on two locks

Soft practice note

Concurrency interviews reward calm structure: hazard → invariant → mechanism → failure mode. If you want a Chrome side panel to rehearse those talk tracks under pressure, Luna Interview is built for that practice loop. Use it to build composure—not to fake systems experience or to violate interview rules.

Day-of checklist

Master the hazards and the bounds—that is concurrency interview basics for seniors.