Advanced Java
Memory, garbage collection, concurrency, functional Java and JVM performance.
These topics assume you are comfortable with the fundamentals.
Articles
- Java Memory ModelWhy concurrent Java code can see stale or reordered values: CPU caches and reordering, the Java Memory Model, happens-before rules, volatile, synchronized and final semantics, safe publication, double-checked locking, data races vs race conditions, and the JVM runtime memory areas (heap, stack, metaspace).
- Garbage collectionHow the JVM reclaims memory: reachability and GC roots, the generational hypothesis, mark-sweep-compact, Serial, Parallel, G1, generational ZGC and Shenandoah compared, pause vs throughput trade-offs, heap sizing in containers, reading GC logs, memory leaks, and recent changes through Java 27.
- Lambdas & StreamsFunctional Java explained: functional interfaces and the java.util.function catalogue, lambdas and capture rules, the four kinds of method references, the Streams API pipeline (lazy evaluation, intermediate and terminal operations), collectors, primitive streams, parallel streams, stream gatherers (Java 24), Optional done right, and performance pitfalls.
- Concurrency APIPractical java.util.concurrent: threads vs tasks, ExecutorService and thread-pool sizing, Future and CompletableFuture composition and error handling, locks (synchronized, ReentrantLock, ReadWriteLock, StampedLock), atomics and LongAdder, synchronizers, concurrent collections and BlockingQueue, and how they relate to virtual threads.
- Virtual threadsJava's lightweight concurrency model: how virtual threads work (mounting, carriers, continuations), when they help, pinning and the Java 24 fix, using them in Spring Boot, structured concurrency for fan-out, scoped values vs ThreadLocal, and comparison with reactive programming.
- Module system (JPMS)Java modules explained: module-info.java, requires, exports, opens and uses/provides, strong encapsulation, the module path vs classpath, automatic and unnamed modules, services, jlink custom runtimes, module import declarations (Java 25), how Spring and frameworks cope, and when modules are worth it.
- Designing concurrent objectsDoug Lea's design forces for concurrent Java — safety, liveness, performance and reusability — and the strategies for thread-safe objects: immutability, confinement, full synchronization, containment, lock splitting, optimistic updates with CAS, deadlock avoidance through lock ordering, and documenting thread-safety policies.
- State-dependent actionsWhat a concurrent object should do when a request arrives in the wrong state: balk, wait (guarded suspension), wait with a timeout, or retry. wait/notify done correctly, Condition objects, a bounded buffer, interruption, the inheritance anomaly, and when to use BlockingQueue and other synchronizers instead.
- Concurrency design patternsHow to introduce threads into an application: oneway messages, thread-per-message, worker threads and pools, completion callbacks, futures and joins, cooperative cancellation, push-flow pipelines, parallel decomposition with fork/join and barriers, and readers-writers — mapped from Doug Lea's patterns to modern Java 21 APIs.
Planned topics
These topics are on the roadmap and not written yet. They appear here so you can see the full scope of the section.
- Class loading
- JVM performance
- Profiling and troubleshooting: JFR, thread dumps, heap dumps