Skip to content
JavaAgentic

Type at least two characters. Try “RAG”, “pgvector” or “tool calling”.

Interview Prep · Phase 4

Concurrency & Multithreading

The Java Memory Model and everything built on it: happens-before, why volatile is not a lock, how to size a thread pool from measurements rather than folklore, composing CompletableFuture chains, and diagnosing a deadlock from a thread dump.

Beginner7 min read

Threads: Lifecycle, Creation and What One Costs

The six thread states and what moves between them, why calling run() directly is a no-op, what a platform thread actually costs in memory and switching, and the interrupt protocol done properly.

Read tutorial
Advanced8 min read

synchronized, Locks and the Java Memory Model

What the Java Memory Model guarantees, why reordering and visibility are separate problems, what synchronized actually does beyond mutual exclusion, and when ReentrantLock earns its extra complexity.

Read tutorial
Intermediate7 min read

volatile, Atomics and the Visibility Problem

What volatile guarantees and what it does not, why count++ is broken even when volatile, how compare-and-swap works, when LongAdder beats AtomicLong, and the double-checked locking idiom.

Read tutorial
Intermediate7 min read

ExecutorService and Thread-Pool Sizing

How ThreadPoolExecutor decides whether to queue or grow, why newFixedThreadPool can exhaust the heap, sizing pools from measurements with Little law, and shutting down without losing work.

Read tutorial
Advanced6 min read

CompletableFuture and Async Composition

Composing async work without blocking: thenApply versus thenCompose, which thread runs each stage, combining with allOf and anyOf, timeouts, and how exceptions propagate through a chain.

Read tutorial
Advanced7 min read

Deadlock, Livelock and Starvation

The four conditions every deadlock needs and how breaking one prevents it, reading a deadlock out of a thread dump, lock ordering and tryLock, and the pool-starvation deadlock with no locks at all.

Read tutorial
Intermediate6 min read

CountDownLatch, Semaphore, CyclicBarrier and Phaser

The coordination primitives in java.util.concurrent, when a latch beats a barrier, using a semaphore as a bulkhead, and the AbstractQueuedSynchronizer that all of them are built on.

Read tutorial
Advanced6 min read

Virtual Threads and Structured Concurrency

How a virtual thread mounts and unmounts from a carrier, why pinning on synchronized still matters, why pooling virtual threads is wrong, and what StructuredTaskScope adds over raw futures.

Read tutorial