Advanced

Advanced & Idiomatic

Tier 5 of the Java book — functional Java, concurrency and the memory model, I/O, modern idioms, and shipping. The Streams API, threads and the happens-before rule, high-level concurrency and virtual threads, the JIT and GC, NIO.2 files, how the modern features compose into data-oriented design, and testing/build/packaging. Every example compiled and run.

Suggest an edit

Advanced & Idiomatic

This is Tier 5, the summit. With the full language and the standard library behind you, these eight chapters cover what separates competent Java from idiomatic, production-grade Java: declarative data processing with streams, the hard truths of concurrency — races, coordination, and the Java Memory Model — how the JVM actually runs and reclaims your code, modern file I/O, the way the modern type-system features compose into one coherent style, and the testing, tooling, and packaging that ship it.

Eight chapters, in order:

  1. Functional Java & the Streams API — lazy pipelines, collectors, Optional, and the parallel-stream hazard.
  2. Concurrency: the Basics — what a thread is, race conditions, synchronized, and happens-before.
  3. Concurrency: Coordinationwait/notify, a real deadlock and its escapes, ReentrantLock, latches, semaphores, and BlockingQueue.
  4. Concurrency: High-Level & Virtual Threads — executors, atomics, CompletableFuture, and virtual threads.
  5. The Java Memory Model & Performancevolatile, happens-before in depth, safe publication, the JIT, and garbage collection.
  6. I/O, Files & NIO.2Path/Files, the stream name clash, and bytes vs characters.
  7. Modern Java Idioms & the Type System — records + sealed + patterns as one data-oriented design.
  8. Testing, Tooling & Packaging — JUnit 5, build tools, dependencies, and executable JARs.

Every code block with a ▶ Run button is live; the concurrency, performance, and tooling chapters include real captured runs (a data race, JIT and GC logs, a mvn test summary) where behavior is nondeterministic or project-level. The habit that matters most at this tier is knowing the cost: streams, parallelism, immutability, and abstractions all have trade-offs, and senior judgment is choosing them deliberately.

📘 How to read the Intuition boxes. Each one is built in three moves:

  1. The mechanism — what the compiler and the JVM are actually doing.
  2. A concrete bite — a specific, runnable failure (often a real compiler error), shown so the trap is visible.
  3. The earned rule — the decision heuristic, now justified rather than asserted, plus its cost.
Mark as read