Concurrency & Multithreading Interview Questions & Answers — Cracked Java
Cracked Java console
0
S
Modules/Concurrency & Multithreading
// MODULE · 12 TOPICS · 76 QUESTIONS

Concurrency & Multithreading

Threads, the Java Memory Model, locks, atomics, executors, CompletableFuture, synchronizers, deadlock, and virtual threads (Loom) — the #1 senior Java filter, from middle to senior interview depth.

0%
Reviewed
0 / 76
Topics done
0 / 12
Est. time left
~45h
Next up
Thread Fundamentals & Lifecycle
12 topics · tap to expand
01

Thread Fundamentals & Lifecycle

JuniorNot started
02

Synchronization & Intrinsic Locks

MidNot started
03

Java Memory Model, volatile & happens-before

SeniorNot started

The contract that makes concurrent code correct: visibility vs atomicity vs ordering, volatile, the happens-before relation, final-field semantics, and why double-checked locking needs volatile.

01What is the Java Memory Model and what problem does it solve?Senior02What does volatile guarantee — and what does it NOT guarantee?Mid03Explain the happens-before relationship. Give the main rules.Senior
04

Explicit Locks: ReentrantLock, ReadWriteLock, StampedLock

SeniorNot started

The java.util.concurrent.locks toolbox — tryLock, fairness, Condition, read/write separation, optimistic reads, and the AbstractQueuedSynchronizer underneath.

01ReentrantLock vs synchronized — what does ReentrantLock add?Mid02What does tryLock() give you, and how does it help avoid deadlock?Mid03What is lock fairness, and what is the cost of a fair lock?Senior
05

Atomics & Compare-And-Swap

SeniorNot started

Lock-free programming primitives: CAS, the Atomic* classes, the ABA problem, LongAdder under contention, and the VarHandle API that replaced Unsafe.

01What is compare-and-swap (CAS) and how does it enable lock-free updates?Mid02What do the java.util.concurrent.atomic classes provide?Mid03What is the ABA problem and how do you solve it?Senior
06

Executors & Thread Pools

SeniorNot started
07

Callable, Future & CompletableFuture

SeniorNot started

Returning results from tasks and composing asynchronous pipelines: Future limitations, thenApply/thenCompose/thenCombine, the *Async variants, exception handling, and allOf/anyOf.

01Future vs Callable vs Runnable — how do they relate?Mid02What are the limitations of plain Future that CompletableFuture fixes?Mid03thenApply vs thenCompose vs thenCombine — when do you use each?Senior
08

Synchronizers: Latch, Barrier, Semaphore, Phaser

MidNot started
09

Deadlock, Livelock & Starvation

SeniorNot started

The four Coffman conditions, how to reproduce and read a deadlock in a thread dump, lock-ordering prevention, and the difference between livelock and starvation.

01What four conditions must hold for a deadlock to occur?Senior02Write code that deadlocks and explain why.Senior03How do you prevent or avoid deadlock?Senior
10

Thread-Safety Patterns

SeniorNot started

Designing for concurrency: what thread-safe really means, immutability, confinement, ThreadLocal and its leak risk, safe publication, and the holder idiom for lazy initialization.

01What does it mean for a class to be thread-safe?Mid02Why are immutable objects inherently thread-safe? How do you make a class immutable?Mid03What is thread confinement (and stack confinement)?Mid
11

Fork/Join & Parallel Streams

SeniorNot started
12

Virtual Threads & Structured Concurrency (Loom)

SeniorNot started

Project Loom: how virtual threads differ from platform threads, mounting/unmounting on carriers, pinning, when to use them, and the structured-concurrency and scoped-value APIs.

01What is the difference between virtual threads and platform threads?Senior02How do virtual threads work? What are carrier threads, mounting, and unmounting?Senior03What is pinning, what causes it, and why does it hurt?Senior