<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chandreyees on Medium]]></title>
        <description><![CDATA[Stories by Chandreyees on Medium]]></description>
        <link>https://medium.com/@chandreyees20?source=rss-9abfb56afbb9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WpMRWP1j1DwpcyK6t6nXUg.jpeg</url>
            <title>Stories by Chandreyees on Medium</title>
            <link>https://medium.com/@chandreyees20?source=rss-9abfb56afbb9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 08:49:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chandreyees20/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What is HTTP? What is a Protocol?]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@chandreyees20/what-is-http-what-is-a-protocol-a5a87a20c827?source=rss-9abfb56afbb9------2"><img src="https://cdn-images-1.medium.com/max/800/1*x0CdGZPOsESRd7Brs_Pgtw.gif" width="800"></a></p><p class="medium-feed-snippet">Understanding HTTP: A Beginner-Friendly Guide</p><p class="medium-feed-link"><a href="https://medium.com/@chandreyees20/what-is-http-what-is-a-protocol-a5a87a20c827?source=rss-9abfb56afbb9------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@chandreyees20/what-is-http-what-is-a-protocol-a5a87a20c827?source=rss-9abfb56afbb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5a87a20c827</guid>
            <category><![CDATA[computer-networking]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[network-security]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <dc:creator><![CDATA[Chandreyees]]></dc:creator>
            <pubDate>Thu, 03 Apr 2025 06:03:15 GMT</pubDate>
            <atom:updated>2025-04-03T06:04:29.853Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Functional Interfaces in Java]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@chandreyees20/functional-interfaces-in-java-3d661cfe5a95?source=rss-9abfb56afbb9------2"><img src="https://cdn-images-1.medium.com/max/866/1*3u6eCFrgwYiJPokwT4Qhow.png" width="866"></a></p><p class="medium-feed-snippet">If you are not a member then use this Link to continue reading.</p><p class="medium-feed-link"><a href="https://medium.com/@chandreyees20/functional-interfaces-in-java-3d661cfe5a95?source=rss-9abfb56afbb9------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@chandreyees20/functional-interfaces-in-java-3d661cfe5a95?source=rss-9abfb56afbb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d661cfe5a95</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java8]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[lambda]]></category>
            <dc:creator><![CDATA[Chandreyees]]></dc:creator>
            <pubDate>Tue, 11 Mar 2025 07:31:01 GMT</pubDate>
            <atom:updated>2025-03-11T08:51:00.700Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Microservices Design Pattern — Part 2]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@chandreyees20/microservices-design-pattern-part-2-60433556ceb1?source=rss-9abfb56afbb9------2"><img src="https://cdn-images-1.medium.com/max/1045/1*WENf0r-BeLRu6GdOgR2jng.png" width="1045"></a></p><p class="medium-feed-snippet">A monolithic application can be broken down into multiple microservices based on different design and functional needs. This includes&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@chandreyees20/microservices-design-pattern-part-2-60433556ceb1?source=rss-9abfb56afbb9------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@chandreyees20/microservices-design-pattern-part-2-60433556ceb1?source=rss-9abfb56afbb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/60433556ceb1</guid>
            <category><![CDATA[strangler-pattern]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Chandreyees]]></dc:creator>
            <pubDate>Sun, 02 Mar 2025 17:31:03 GMT</pubDate>
            <atom:updated>2025-03-02T17:32:38.394Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Microservices Design Pattern — Part 1]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@chandreyees20/microservices-design-pattern-part-1-c2db75d7bbeb?source=rss-9abfb56afbb9------2"><img src="https://cdn-images-1.medium.com/max/779/1*YHM7QRSdP54nVbiOd9hEMQ.png" width="779"></a></p><p class="medium-feed-snippet">Microservices rely on various design patterns for scalability, maintainability, and data consistency. In this blog, we&#x2019;ll explore three&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@chandreyees20/microservices-design-pattern-part-1-c2db75d7bbeb?source=rss-9abfb56afbb9------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@chandreyees20/microservices-design-pattern-part-1-c2db75d7bbeb?source=rss-9abfb56afbb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2db75d7bbeb</guid>
            <category><![CDATA[cqrs-pattern]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[saga-pattern]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <dc:creator><![CDATA[Chandreyees]]></dc:creator>
            <pubDate>Fri, 21 Feb 2025 08:11:15 GMT</pubDate>
            <atom:updated>2025-02-21T11:58:11.566Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Understanding SOLID Principles]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@chandreyees20/understanding-solid-principles-7df45a4ec6d6?source=rss-9abfb56afbb9------2"><img src="https://cdn-images-1.medium.com/max/2600/1*PdHbMwTMwKnfElddzFxIlA.png" width="4705"></a></p><p class="medium-feed-snippet">While working on industry projects, I often encountered challenges related to code scalability and maintainability. This led me to explore&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@chandreyees20/understanding-solid-principles-7df45a4ec6d6?source=rss-9abfb56afbb9------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@chandreyees20/understanding-solid-principles-7df45a4ec6d6?source=rss-9abfb56afbb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/7df45a4ec6d6</guid>
            <category><![CDATA[core-java]]></category>
            <category><![CDATA[low-level-design]]></category>
            <category><![CDATA[oop-concepts]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <dc:creator><![CDATA[Chandreyees]]></dc:creator>
            <pubDate>Mon, 30 Dec 2024 09:06:42 GMT</pubDate>
            <atom:updated>2024-12-31T17:08:02.707Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Unraveling Java Memory Management: Stack, Heap, and the Java Memory Model (JMM)]]></title>
            <link>https://medium.com/@chandreyees20/unraveling-java-memory-management-stack-heap-and-the-java-memory-model-jmm-657282250ca8?source=rss-9abfb56afbb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/657282250ca8</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[memory-management]]></category>
            <category><![CDATA[core-java]]></category>
            <dc:creator><![CDATA[Chandreyees]]></dc:creator>
            <pubDate>Mon, 23 Dec 2024 14:40:56 GMT</pubDate>
            <atom:updated>2024-12-23T14:40:56.511Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>As a developer, I’ve always been curious about how Java handles memory so efficiently. It feels like magic — until you dig in and realize it’s all about mastering the fundamentals.</blockquote><blockquote>While prepping for interviews and building applications, I kept running into terms like <strong>Stack</strong>, <strong>Heap</strong>, and the <strong>Happens-Before relationship</strong>. They sounded intimidating at first, but once I started exploring, things clicked.</blockquote><blockquote>This blog is my attempt to break down these concepts in a way that’s practical and easy to grasp.</blockquote><p>In this blog, I’ll walk you through:</p><ul><li>The difference between <strong>Stack</strong> and <strong>Heap</strong>, and how they allocate memory.</li><li>The workings of the <strong>Java Memory Model (JMM)</strong> and its role in thread synchronization.</li><li>The “Happens-Before” relationship, explained with practical examples.</li></ul><h3><strong>Stack vs Heap</strong></h3><blockquote>Java’s memory is divided into two parts: <strong>Stack</strong> (stores variables and methods) and <strong>Heap</strong> (dynamic allocation of objects).</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*RrSCgOy39qMR_M--mS2SKA.png" /></figure><h4>Stack</h4><p>The <strong>Stack</strong> is a special memory area in Java used for temporary storage and method execution. Here’s how it works:</p><ul><li><strong>Stores Primitive Values</strong>: All local variables of primitive data types (e.g., int, float, char) are stored in the stack.</li><li><strong>Method Call Storage</strong>: Memory blocks for method execution (method frames) are allocated in the stack. This includes method parameters and local variables.</li><li><strong>Reference Variables</strong>: While objects are stored in the heap, their references (pointers) are stored in the stack.</li><li><strong>LIFO (Last-In, First-Out) Operation</strong>: The stack operates like a stack of plates — memory is allocated and deallocated in the reverse order of allocation. Each method call creates a new stack frame, which is removed once the method execution completes.</li><li><strong>Thread-Specific</strong>: Each thread in Java has its own stack, ensuring thread safety for local variables.</li><li><strong>Stack Size</strong>: Limited in size; an excessive number of recursive method calls can lead to a StackOverflowError.</li></ul><h4>Heap</h4><p>The <strong>Heap</strong> is the main area of memory used for dynamic allocation, where objects and class instances are stored. Key characteristics include:</p><ul><li><strong>Object Storage</strong>: All objects and class-level variables (static fields) are stored in the heap.</li><li><strong>Managed by Garbage Collector</strong>: The Java Garbage Collector automatically identifies and removes objects that are no longer reachable, freeing up memory.</li><li><strong>Unordered Structure</strong>: Unlike the stack, objects in the heap are stored in an unordered manner, and memory is allocated as needed.</li><li><strong>Shared Across Threads</strong>: The heap is shared among all threads, making it critical to manage synchronization when accessing shared objects.</li><li><strong>Heap Size</strong>: Configurable using JVM options (-Xms for initial size, -Xmx for maximum size). Insufficient heap memory leads to an OutOfMemoryError.</li></ul><pre>public class MemoryExample {<br>    public static void main(String[] args) {<br>        int x = 10; // Allocated in the stack<br>        String name = &quot;Java&quot;; // Reference in the stack, object in the heap<br>        Student student = new Student(); // Object in the heap<br>    }<br>}</pre><h3><strong>Java Memory Model (JMM)</strong></h3><p>The <strong>Java Memory Model (JMM)</strong> defines the rules and guarantees about how threads interact with memory, ensuring predictable and consistent behavior in multithreaded programs.</p><blockquote>What Does the JMM Solve?</blockquote><blockquote><strong>Stale Data Due to Cache and Registers</strong><br>Threads may read outdated values because modern CPUs and compilers optimize performance by delaying updates to shared variables.</blockquote><blockquote><strong>Instruction Reordering</strong><br>To improve performance, the compiler or processor may rearrange instructions, leading to unexpected outcomes in multithreaded environments.</blockquote><p><strong>Core Principles of the JMM</strong></p><p><strong>Shared Variables</strong></p><ul><li>Stored in main memory.</li><li>Threads maintain their own local copy of shared variables in <strong>working memory</strong>, leading to potential inconsistencies.</li><li>Without proper synchronization, one thread’s changes might not be visible to another.</li></ul><p><strong>Visibility</strong></p><ul><li>Declaring a variable with the volatile keyword ensures that all threads read/write directly from/to main memory.</li><li>Changes to volatile variables are immediately visible to all threads.</li></ul><p><strong>Atomicity</strong></p><ul><li>Operations like reading/writing <strong>int</strong>, <strong>long</strong>, and reference variables are atomic by default.</li></ul><p><strong>Ordering</strong></p><ul><li>Without synchronization, the JVM and hardware may reorder instructions for performance.</li><li>The JMM defines a <strong>partial order</strong> to ensure consistent results when properly synchronized.</li></ul><h3>The Happens-Before Relationship</h3><p>This is the backbone of the JMM, defining how operations are ordered and when one thread’s actions are visible to another.</p><blockquote>These rules are straightforward and practical, designed to align with intuitive expectations for thread interactions.</blockquote><p><strong>Happens-Before Rules</strong></p><ol><li><strong>Program Order Rule: </strong>In a single threaded environment instructions get executed in the order they appear.</li><li><strong>Monitor Lock Rule: </strong>When a thread unlocks a synchronized block or method, the changes made inside the block are visible to the next thread that locks the same monitor.</li></ol><pre>class SharedResource {<br>    private int data = 0;<br><br>    public synchronized void writeData(int value) {<br>        data = value; // Happens-before unlock<br>    }<br><br>    public synchronized int readData() {<br>        return data; // Happens-after lock<br>    }<br>}<br><br>public class Main {<br>    public static void main(String[] args) {<br>        SharedResource resource = new SharedResource();<br><br>        Thread writer = new Thread(() -&gt; resource.writeData(42));<br>        Thread reader = new Thread(() -&gt; System.out.println(resource.readData()));<br><br>        writer.start();<br>        reader.start();<br>    }<br>}</pre><ol><li><strong>Volatile Variable Rule:</strong> When a thread writes to a volatile variable, it is guaranteed to be visible to other threads immediately.</li><li><strong>Thread Start Rule: </strong>When a thread is started using Thread.start(), all actions before the start in the main thread are visible to the new thread.</li><li><strong>Thread Join Rule: </strong>When a thread finishes execution and another thread calls join() on it, all actions done by the joined thread happen-before the join() returns.</li><li><strong>Transitivity Rule: </strong>If one action happens-before a second action, and the second action happens-before a third, then the first action happens-before the third.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=657282250ca8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>