<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Advanced Java on Java &amp; Software Architecture Knowledge Hub</title><link>https://samirsahoo.github.io/design-patterns-hub/java/advanced/</link><description>Recent content in Advanced Java on Java &amp; Software Architecture Knowledge Hub</description><generator>Hugo</generator><language>en-US</language><copyright>© 2026 Samir Kumar Sahoo (https://github.com/samirsahoo). All rights reserved.</copyright><atom:link href="https://samirsahoo.github.io/design-patterns-hub/java/advanced/index.xml" rel="self" type="application/rss+xml"/><item><title>The Java Memory Model and Happens-Before</title><link>https://samirsahoo.github.io/design-patterns-hub/java/advanced/java-memory-model/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/java/advanced/java-memory-model/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;The &lt;strong&gt;Java Memory Model (JMM)&lt;/strong&gt;, defined in chapter 17 of the Java Language Specification, specifies &lt;strong&gt;when a write made by one thread is guaranteed to be visible to another&lt;/strong&gt;. It defines a &lt;strong&gt;happens-before&lt;/strong&gt; relation: if action A happens-before action B, then B sees A&amp;rsquo;s effects.&lt;/p&gt;</description></item><item><title>Garbage Collection: G1, ZGC and Tuning Basics</title><link>https://samirsahoo.github.io/design-patterns-hub/java/advanced/garbage-collection/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/java/advanced/garbage-collection/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;&lt;strong&gt;Garbage collection (GC)&lt;/strong&gt; automatically frees heap memory used by objects that the program &lt;strong&gt;can no longer reach&lt;/strong&gt;. The JVM ships several collectors that trade &lt;strong&gt;pause time&lt;/strong&gt;, &lt;strong&gt;throughput&lt;/strong&gt; and &lt;strong&gt;memory overhead&lt;/strong&gt; differently.&lt;/p&gt;&#10;&lt;h2 id="the-problem"&gt;The problem&lt;a class="heading-anchor" href="#the-problem" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Manual memory management causes leaks and use-after-free bugs. Automatic GC removes those but costs CPU and sometimes &lt;strong&gt;pauses&lt;/strong&gt; the application. The right collector and heap size can turn 2-second pauses into sub-millisecond ones, or double throughput.&lt;/p&gt;</description></item><item><title>Functional Programming in Java: Lambdas, Method References and Streams</title><link>https://samirsahoo.github.io/design-patterns-hub/java/advanced/functional-programming-and-streams/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/java/advanced/functional-programming-and-streams/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;&lt;strong&gt;Functional programming in Java&lt;/strong&gt; means passing &lt;strong&gt;behaviour as values&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;lambdas&lt;/strong&gt; and &lt;strong&gt;method references&lt;/strong&gt; implement &lt;strong&gt;functional interfaces&lt;/strong&gt; (interfaces with one abstract method)&lt;/li&gt;&#10;&lt;li&gt;the &lt;strong&gt;Streams API&lt;/strong&gt; processes data declaratively: you say &lt;strong&gt;what&lt;/strong&gt; to compute (filter, map, group), not &lt;strong&gt;how&lt;/strong&gt; to loop.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="the-problem"&gt;The problem&lt;a class="heading-anchor" href="#the-problem" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Loops mix the &amp;ldquo;what&amp;rdquo; with the &amp;ldquo;how&amp;rdquo;: index variables, temporary collections and mutable accumulators. Anonymous inner classes for callbacks were verbose. Lambdas and streams make data transformations shorter and clearer, and easier to parallelise &lt;strong&gt;when&lt;/strong&gt; that helps.&lt;/p&gt;</description></item><item><title>The Java Concurrency API: Executors, CompletableFuture, Locks and Concurrent Collections</title><link>https://samirsahoo.github.io/design-patterns-hub/java/advanced/concurrency-api/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/java/advanced/concurrency-api/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;&lt;code&gt;java.util.concurrent&lt;/code&gt; provides &lt;strong&gt;higher-level building blocks&lt;/strong&gt; for running work in parallel and coordinating threads safely:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;executors&lt;/strong&gt; run tasks&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;futures&lt;/strong&gt; represent results that arrive later&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;locks and atomics&lt;/strong&gt; protect shared state&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;concurrent collections&lt;/strong&gt; are safe to share between threads.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="the-problem"&gt;The problem&lt;a class="heading-anchor" href="#the-problem" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Creating raw &lt;code&gt;Thread&lt;/code&gt;s per task does not scale (platform threads are expensive OS threads). Hand-written &lt;code&gt;wait&lt;/code&gt;/&lt;code&gt;notify&lt;/code&gt; code is notoriously buggy. Sharing a plain &lt;code&gt;HashMap&lt;/code&gt; between threads corrupts it. The concurrency API gives tested abstractions, so you rarely touch low-level primitives.&lt;/p&gt;</description></item><item><title>Virtual Threads, Structured Concurrency and Scoped Values</title><link>https://samirsahoo.github.io/design-patterns-hub/java/advanced/virtual-threads-and-structured-concurrency/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/java/advanced/virtual-threads-and-structured-concurrency/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;A &lt;strong&gt;virtual thread&lt;/strong&gt; (Java 21, Project Loom) is a &lt;code&gt;Thread&lt;/code&gt; managed by the JVM rather than the operating system. It is so cheap that you can create &lt;strong&gt;millions&lt;/strong&gt;, one per request or task. When it blocks on I/O, the JVM &lt;strong&gt;parks&lt;/strong&gt; it and frees the underlying OS thread for other work.&lt;/p&gt;</description></item><item><title>The Java Platform Module System (JPMS)</title><link>https://samirsahoo.github.io/design-patterns-hub/java/advanced/java-module-system/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/java/advanced/java-module-system/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;The &lt;strong&gt;Java Platform Module System (JPMS)&lt;/strong&gt;, introduced in Java 9 (Project Jigsaw), groups packages into &lt;strong&gt;modules&lt;/strong&gt; with explicit &lt;strong&gt;dependencies&lt;/strong&gt; (&lt;code&gt;requires&lt;/code&gt;) and an explicit &lt;strong&gt;public API&lt;/strong&gt; (&lt;code&gt;exports&lt;/code&gt;). Everything else is &lt;strong&gt;strongly encapsulated&lt;/strong&gt;: other modules cannot use it, even through reflection.&lt;/p&gt;</description></item><item><title>Designing Concurrent Objects: Safety, Liveness and Locking Strategies</title><link>https://samirsahoo.github.io/design-patterns-hub/java/advanced/concurrent-object-design/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/java/advanced/concurrent-object-design/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;A &lt;strong&gt;thread-safe&lt;/strong&gt; class behaves correctly when its methods are called from several threads at the same time, without callers needing extra synchronization. Designing one means balancing four forces that Doug Lea describes in &lt;em&gt;Concurrent Programming in Java&lt;/em&gt;:&lt;/p&gt;</description></item><item><title>State-Dependent Actions: Balking, Guarded Suspension and Timeouts</title><link>https://samirsahoo.github.io/design-patterns-hub/java/advanced/state-dependent-actions/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/java/advanced/state-dependent-actions/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;A &lt;strong&gt;state-dependent action&lt;/strong&gt; is an operation that only makes sense when an object is in a certain state: you cannot take an item from an empty queue, withdraw from an empty account, or start an engine that is already running. In a single-threaded program, the wrong state is an error. In a concurrent program, the state might become right &lt;strong&gt;if you wait&lt;/strong&gt;, because another thread may change it.&lt;/p&gt;</description></item><item><title>Concurrency Design Patterns: Messages, Worker Threads, Futures, Cancellation and Pipelines</title><link>https://samirsahoo.github.io/design-patterns-hub/java/advanced/concurrency-design-patterns/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/java/advanced/concurrency-design-patterns/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Once objects are safe to share (see &lt;a href="https://samirsahoo.github.io/design-patterns-hub/java/advanced/concurrent-object-design/"&gt;Designing concurrent objects&lt;/a&gt;), the next question is &lt;strong&gt;how work gets onto threads&lt;/strong&gt; and how results and failures come back. Doug Lea&amp;rsquo;s &lt;em&gt;Concurrent Programming in Java&lt;/em&gt; catalogues the recurring answers. Most now have direct support in &lt;code&gt;java.util.concurrent&lt;/code&gt;, so this page names each pattern, explains the forces behind it, and shows the modern API.&lt;/p&gt;</description></item></channel></rss>