<?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 Somnath Musib on Medium]]></title>
        <description><![CDATA[Stories by Somnath Musib on Medium]]></description>
        <link>https://medium.com/@musibs?source=rss-b7dd955599ca------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*T-GAjFjrQaFLev-BIrbnwg.jpeg</url>
            <title>Stories by Somnath Musib on Medium</title>
            <link>https://medium.com/@musibs?source=rss-b7dd955599ca------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 09:59:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@musibs/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[Understanding Load Balancers — A technical deep dive]]></title>
            <link>https://medium.com/thebackendtech/understanding-load-balancers-a-technical-deep-dive-ff8d73f6d8df?source=rss-b7dd955599ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff8d73f6d8df</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Somnath Musib]]></dc:creator>
            <pubDate>Fri, 29 Aug 2025 11:35:05 GMT</pubDate>
            <atom:updated>2025-08-29T12:00:55.029Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding Load Balancers — A technical deep dive</h3><h4>Architecting Scalable and Resilient Systems Through Strategic Load Distribution</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LVairarUs-Xs9tWg" /><figcaption>Image Courtesy: <a href="https://unsplash.com/photos/three-traffic-lights-hanging-from-a-wire-with-a-blue-sky-in-the-background-Y-W7GoXLJgw">https://unsplash.com/photos/three-traffic-lights-hanging-from-a-wire-with-a-blue-sky-in-the-background-Y-W7GoXLJgw</a></figcaption></figure><p>A load balancer distributes incoming network traffic across multiple servers to ensure that no single server is overloaded, and the traffic is uniformly distributed. This improves the application availability, scalability, performance and the reliability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*V-SANWM4p3vH2VCA4j-pqQ.png" /></figure><h3><strong>Types of load balancer</strong></h3><h4><strong><em>By OSI Layer: Layer 4 &amp; Layer 7</em></strong></h4><p>A load balancer can operate at transport layer (Layer 4) or at the application layer (Layer 7).</p><p>A layer 4 load balancer routes the request based on IP address and port. This load balancers are fast and works with TCP or UDP protocols. An example of layer 4 load balancer is AWS Network Load Balancer (NLB).</p><p>A layer 7 load balancer operates on the application layer and routes the incoming request based on the content, such as HTTP headers, URLs, cookies, and so on. It can make more intelligent routing decisions as it operates on the application layer, and it can also modify the HTTP request and the response. This load balancer performs slower than the layer 4 load balancer due to the HTTP processing overhead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*gVEKboK2QHjjI9gPR1URRg.png" /><figcaption>Layer 7 Load Balancer</figcaption></figure><h4><strong><em>By Deployment: Hardware &amp; software load balancer</em></strong></h4><p>We can also categorize the load balancers based on hardware or software level load balancers. A hardware load balancer is a physical appliance that is purpose-built for load balancing. An example of hardware load balancer is F5 BIG-IP (https://www.f5.com/products/big-ip).</p><p>Software load balancer, as the name indicates is implemented through the software. Examples of software load balancers are Ngnix, Apache HTTP Server (using mod_proxy_balancer module), HAProxy etc.</p><h4><strong><em>By Architecture: Reverse &amp; Forward Proxy</em></strong></h4><p>Based on how the load balancer operates, it can be a reverse proxy or a forward proxy. It is called as proxy as it hides the client and proxy the request on their behalf.</p><p>A reverse proxy load balancer sits between client and servers and hides the backend server details to the client. Client always interacts with the load balancer. This type is the primary usage of the load balancers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*tKnPklq5r39ePo5lJAkqmQ.png" /><figcaption>Reverse proxy</figcaption></figure><p>A forward proxy load balancer sits between client and the internet/web server and hides the actual client details to the internet/web servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*B-JVFe2iBaSBEcwOkrgRaQ.png" /><figcaption>Forward Proxy</figcaption></figure><h3>Load Balancer Algorithms</h3><p>Load balancer algorithms can be categorized into two types — static and dynamic. Let’s understand the static types:</p><h4>Round Robin</h4><p>In round robin algorithm, the load balancer routes the requests in a round robin fashion to the backend servers.</p><p>With this algorithm, the load balancer maintains a circular list of available servers and an index pointer that advances with each request. When a request arrives, the load balancer selects the server at the current index position, forwards the request, and increments the index to the next server in the list. Once the index reaches the end of the server list, it wraps around to the beginning, ensuring equal distribution across all available servers. This stateful approach requires the load balancer to track both the server pool and the current position, making it simple to implement but requiring careful handling during server pool changes and load balancer restarts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OCwnQOUUtbEr7YOfuvr1Hg.png" /><figcaption>Figure Round robin load balancing</figcaption></figure><p>In the above diagram, the load balancer maintains the list of server pool [s0, s1 and s2] and an index initialized with 0. For the first request, it applies 3%0=0 and routes to the first server. It then increments the index by 1. For the next request, it applies 1%3=1 and the request is routed to server 2.</p><h4>Weighted Round-Robin</h4><p>This algorithm is useful when the servers are of varied capacity. I.e. some servers have more processing power and capacity while some have less processing capacity. Thus, instead of treating all servers equally, weighted round-robin assigns a weight value to each server based on its relative capacity and distributes requests proportionally to these weights. For example, if Server A has weight 3, Server B has weight 2, and Server C has weight 1, then out of every 6 requests, Server A receives 3 requests, Server B receives 2 requests, and Server C receives 1 request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SOs6kPBKes9LPplCSPJfXw.png" /><figcaption>Figure Weighted round-robin</figcaption></figure><h4>IP Hash</h4><p>IP Hash algorithm uses the client’s IP address as input to a hash function to determine which backend server should handle the request.</p><p>The load balancer calculates a hash value from the client’s IP address and uses modulo operation with the number of available servers to select the target server. This ensures that requests from the same client IP will consistently be routed to the same backend server. This provides implicit session affinity without any server-side session storage or cookie management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n_0h4pClRh628F1zPNDADQ.png" /><figcaption>Figure: IP Hash</figcaption></figure><p>In the above example, a client with IP address 192.168.1.100 requests load balancer. It then applies the hash on the IP address and generates a hash value and applies modulo operation to find the server index. The request is forwarded to the server, in this case server 0. All subsequent requests are also forwarded to the same server.</p><p>Most enterprise grade load balancers use <a href="https://en.wikipedia.org/wiki/Consistent_hashing">consistent hashing</a> or ring-based approaches to minimize server reassignment when the backend server pool changes.</p><p>Next, lets discuss the dynamic types:</p><h4>Least Connections</h4><p>The Least Connections algorithm routes incoming requests to the backend server that currently has the fewest active connections.</p><p>This approach provides better load distribution than round-robin <strong>when request processing times vary significantly</strong>, as it automatically adapts to server performance differences. The load balancer maintains a real-time count of active connections for each server, incrementing the count when forwarding a request and decrementing it when the connection closes or the response is returned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*6LUFkjhTIEVaw6w9Qglvww.png" /><figcaption>Figure: Least Connections</figcaption></figure><h4>Weighted Least Connections</h4><p>Weighted Least Connections combines the least connections algorithm with the weighted round-robin. Each server is assigned a weight based on its capacity. The algorithm routes requests to the server with the lowest ratio of current connections to the assigned weight. This approach ensures that high-capacity servers can handle proportionally more concurrent connections while still adapting to real-time load variations and varying request processing times.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JYApqPEmlx_8X6PEEvGoSg.png" /><figcaption>Figure: Weighted Least Connections</figcaption></figure><h3>Conclusion</h3><p>In this article, we explored the concept of load balancing. We discussed the different types of load balancers, including Layer 4 (transport layer) and Layer 7 (application layer). Additionally, we examined various load balancing algorithms, such as Round Robin, Weighted Round Robin, IP Hash, Least Connections, Weighted Least Connections with detailed explanations on how each algorithm distributes traffic.</p><p><em>If you like this article, you can subscribe to my newsletter at </em><a href="https://musibs.substack.com/"><em>https://musibs.substack.com/</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff8d73f6d8df" width="1" height="1" alt=""><hr><p><a href="https://medium.com/thebackendtech/understanding-load-balancers-a-technical-deep-dive-ff8d73f6d8df">Understanding Load Balancers — A technical deep dive</a> was originally published in <a href="https://medium.com/thebackendtech">The Backend Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Java Concurrency: Blocking Queue Implementations (Part 1)]]></title>
            <link>https://levelup.gitconnected.com/mastering-java-concurrency-blocking-queue-implementations-part-1-abcc6ebffb06?source=rss-b7dd955599ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/abcc6ebffb06</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Somnath Musib]]></dc:creator>
            <pubDate>Thu, 14 Nov 2024 21:28:26 GMT</pubDate>
            <atom:updated>2024-11-14T21:28:26.889Z</atom:updated>
            <content:encoded><![CDATA[<h4>A Guide to Using Various <strong>BlockingQueue </strong>Implementations in Java</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Fdcae5kuLFMql-hP" /><figcaption>Picture Courtesy: Alexandr Bormotin, <a href="https://unsplash.com/photos/aerial-photography-of-street-at-night-covered-with-snow-w6KSwwnQyaE">https://unsplash.com/photos/aerial-photography-of-street-at-night-covered-with-snow-w6KSwwnQyaE</a></figcaption></figure><p>A BlockingQueue is a special type of queue implementation that adds capabilities to a Java queue. It allows <strong>threads to be blocked when it attempts to add or remove items from the queue under certain conditions</strong> (e.g. the queue is full or empty).</p><p>In this article, we’ll explore various BlockingQueue implementations available in the java.util.concurrent package.</p><p>Let us begin with a summary of the <em>BlockingQueue</em>, <em>TransferQueue </em>interface and the implementing classes. The following is a class diagram representing the interfaces and classes of the <em>BlockingQueue </em>family. In the diagram, a dotted arrow represents an <em>extension </em>and a solid arrow represents an <em>implementation</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*09UnXUWm_3DKz1CRBBYG0w.png" /><figcaption>Figure 1 : BlockingQueue Implementations</figcaption></figure><h4>BlockingQueue</h4><p>This is the <strong>central interface that enables the blocking capabilities in a Java queue</strong>. It supports operations that wait for the queue to become non-empty when retrieving an element, and wait for space to become available in the queue when storing an element.</p><p>The following are the main characteristics of this interface:</p><ol><li><strong><em>BlockingQueue </em>implementations are thread-safe</strong>. All queuing methods achieve their effects atomically using internal locks or other forms of concurrency control.</li><li><strong>A <em>BlockingQueue </em>may be capacity bounded</strong>. A <em>BlockingQueue</em><strong><em> </em></strong>without any capacity constraints allows a maximum capacity of <em>Integer.MAX_VALUE</em>.</li><li><strong>A <em>BlockingQueue</em></strong><em> </em><strong>does <em>not</em> intrinsically support any kind of <em>close </em>or <em>shutdown</em> operation</strong> to indicate that no more items will be added.</li><li><strong>A <em>BlockingQueue </em>does not accept null elements</strong>. It throws <em>NullPointerException</em> on attempts to <em>add</em>, <em>put </em>or <em>offer</em> a <em>null</em>. A <em>null </em>is used as a sentinel value to indicate the failure of <em>poll </em>operations.</li><li><em>BlockingQueue</em> implementations are primarily designed to be used for <strong>producer-consumer queues</strong>.</li></ol><p>BlockingQueue interface methods come in the following four forms:</p><ol><li>Throws an exception</li><li>Returns a special value (either null or false, depending on the operation)</li><li>Blocks the current thread indefinitely until the operation can succeed</li><li>Blocks for only a given maximum time limit before giving up</li></ol><p>The below image summarizes the BlockingQueue methods based on the above four categories:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*C-3N8AcRgNemhoEMYCuuLw.png" /></figure><h4>TransferQueue</h4><p>A TransferQueue is a special type of BlockingQueue that supports additional methods to <strong>facilitate the direct handoff of elements from producers to consumers</strong>. Thus, making it especially useful in scenarios where producers want to wait until their elements are consumed before proceeding further.</p><p>Let us explore the usage of TransferQueue with the following code example. We are using the LinkedTransferQueue as the TransferQueue implementation:</p><pre>import java.util.concurrent.LinkedTransferQueue;<br>import java.util.concurrent.TransferQueue;<br><br>public class TransferQueueExample {<br>    public static void main(String[] args) {<br>        TransferQueue&lt;String&gt; queue = new LinkedTransferQueue&lt;&gt;();<br><br>        // Consumer Thread<br>        Thread consumer = new Thread(() -&gt; {<br>            try {<br>                System.out.println(&quot;Consumer waiting to take an item...&quot;);<br>                String item = queue.take(); // Blocks until an item is available<br>                System.out.println(&quot;Consumer received: &quot; + item);<br>            } catch (InterruptedException e) {<br>                Thread.currentThread().interrupt();<br>                System.out.println(&quot;Consumer interrupted&quot;);<br>            }<br>        });<br><br>        // Producer Thread<br>        Thread producer = new Thread(() -&gt; {<br>            try {<br>                String item = &quot;Hello from producer!&quot;;<br>                System.out.println(&quot;Producer transferring: &quot; + item);<br>                queue.transfer(item); // Waits until the item is received by the consumer<br>                System.out.println(&quot;Producer completed transfer&quot;);<br>            } catch (InterruptedException e) {<br>                Thread.currentThread().interrupt();<br>                System.out.println(&quot;Producer interrupted&quot;);<br>            }<br>        });<br><br>        consumer.start();<br>        producer.start();<br>    }<br>}</pre><p>In the above code snippet, we are creating a producer and consumer running in two different threads. The producer communicates to the consumer via the LinkedTransferQueue. It produces a message and transfers it to the consumer through LinkedTransferQueue.</p><p>The key point to note here is the use of the transfer method in the producer thread. It blocks until the consumer consumes the message. Thus, enabling a direct handoff of the message to the consumer.</p><p>The following is the output:</p><pre>Producer transferring: Hello from producer!<br>Consumer waiting to take an item...<br>Consumer received: Hello from producer!<br>Producer completed transfer</pre><p>Next, we’ll explore the use of the <em>tryTransfer()</em> method of the TransferQueue. As the name suggests, this method lets a producer transfer an element to a consumer. However, if no consumer is available, then the method returns false. The following code snippet shows this:</p><pre>import java.util.concurrent.LinkedTransferQueue;<br>import java.util.concurrent.TransferQueue;<br><br>public class TryTransferExample {<br>    public static void main(String[] args) {<br>        TransferQueue&lt;String&gt; queue = new LinkedTransferQueue&lt;&gt;();<br><br>        // Producer Thread<br>        Thread producer = new Thread(() -&gt; {<br>            String item = &quot;Immediate Transfer&quot;;<br>            boolean transferred = queue.tryTransfer(item);<br>            System.out.println(&quot;Immediate transfer success: &quot; + transferred);<br>        });<br><br>        // No consumer waiting, so tryTransfer() will return false<br>        producer.start();<br>    }<br>}</pre><p>The following is the output of the above code snippet:</p><pre>Immediate transfer success: false</pre><p>Note that there is a variant of the <em>tryTransfer(..)</em> method that allows a producer to try the transfer and wait for a specific duration. If the element is not consumed by the specified duration, the <em>tryTransfer(..)</em> returns false. The following code snippet demonstrates this:</p><pre>import java.util.concurrent.LinkedTransferQueue;<br>import java.util.concurrent.TimeUnit;<br>import java.util.concurrent.TransferQueue;<br><br>public class TryTransferWithTimeoutExample {<br>    public static void main(String[] args) {<br>        TransferQueue&lt;String&gt; queue = new LinkedTransferQueue&lt;&gt;();<br><br>        // Producer Thread<br>        Thread producer = new Thread(() -&gt; {<br>            String item = &quot;Timed Transfer&quot;;<br>            try {<br>                boolean transferred = queue.tryTransfer(item, 2, TimeUnit.SECONDS);<br>                System.out.println(&quot;Transfer success after waiting: &quot; + transferred);<br>            } catch (InterruptedException e) {<br>                Thread.currentThread().interrupt();<br>                System.out.println(&quot;Producer interrupted&quot;);<br>            }<br>        });<br><br>        // No consumer waiting, so tryTransfer() will wait up to 2 seconds<br>        producer.start();<br>    }<br>}</pre><h4><strong>ArrayBlockingQueue</strong></h4><p>An <em>ArrayBlockingQueue </em>is a <em>BlockingQueue </em>implementation that provides a bounded queue backed by an array. This queue offers a First-In-First-Out (FIFO) order i.e. the head of the queue contains the element which is the longest time in the queue and the tail contains the element that is the shortest time in the queue.</p><p>An ArrayBlocking queue is a bounded queue i.e. it is created with a specific size. Once the queue is created, its capacity can’t be modified. Once the queue is full, the put operation blocks. Similarly, if the queue is empty, the take operation blocks.</p><p>The following are operations summary supported by this queue:</p><p><strong>Adding Elements</strong>:</p><ul><li>add(E e): Inserts an element, throwing an exception if the queue is full.</li><li>offer(E e): Attempts to add an element, returning false if the queue is full.</li><li>put(E e): Inserts an element, waiting if necessary until space becomes available.</li></ul><p><strong>Removing Elements</strong>:</p><ul><li>take(): Retrieves and removes the head of the queue, waiting if necessary until an element is available.</li><li>poll(): Retrieves and removes the head, returning null if the queue is empty.</li><li>poll(long timeout, TimeUnit unit): Waits for the specified time for an element to be available and then retrieves and removes it.</li></ul><p><strong>Inspection</strong>:</p><ul><li>peek(): Retrieves, but does not remove, the head of the queue, or returns null if the queue is empty.</li><li>remainingCapacity(): Returns the number of additional elements the queue can accept without blocking.</li></ul><p>The following is the code example of using an ArrayBlockingQueue:</p><pre>import java.util.concurrent.ArrayBlockingQueue;<br>import java.util.concurrent.BlockingQueue;<br><br>public class ArrayBlockingQueueExample {<br>    public static void main(String[] args) {<br>        // Create an ArrayBlockingQueue with a capacity of 5<br>        BlockingQueue&lt;String&gt; queue = new ArrayBlockingQueue&lt;&gt;(5);<br><br>        // Producer Thread<br>        Thread producer = new Thread(() -&gt; {<br>            try {<br>                for (int i = 1; i &lt;= 10; i++) {<br>                    String item = &quot;Item &quot; + i;<br>                    System.out.println(&quot;Producer adding: &quot; + item);<br>                    queue.put(item); // Blocks if the queue is full<br>                    System.out.println(&quot;Producer added: &quot; + item);<br>                }<br>            } catch (InterruptedException e) {<br>                Thread.currentThread().interrupt();<br>                System.out.println(&quot;Producer interrupted&quot;);<br>            }<br>        });<br><br>        // Consumer Thread<br>        Thread consumer = new Thread(() -&gt; {<br>            try {<br>                while (true) {<br>                    String item = queue.take(); // Blocks if the queue is empty<br>                    System.out.println(&quot;Consumer took: &quot; + item);<br>                    Thread.sleep(500); // Simulate processing time<br>                }<br>            } catch (InterruptedException e) {<br>                Thread.currentThread().interrupt();<br>                System.out.println(&quot;Consumer interrupted&quot;);<br>            }<br>        });<br><br>        producer.start();<br>        consumer.start();<br>    }<br>}</pre><h4>LinkedBlockingQueue</h4><p>A <em>LinkedBlockingQueue </em>is an optionally bounded <em>BlockingQueue</em> implementation based on linked nodes. It can be a bounded queue if created with a specific size or an unbounded queue if no size is specified. For an unbounded queue, the size is Integre.MAX_VALUE.</p><p>The following code example shows the use of <em>LinkedBlockingQueue </em>as a bounded queue:</p><pre>import java.util.concurrent.BlockingQueue;<br>import java.util.concurrent.LinkedBlockingQueue;<br><br>public class LinkedBlockingQueueExample {<br><br>    public static void main(String[] args) {<br>        // Create a LinkedBlockingQueue with a capacity of 3<br>        BlockingQueue&lt;String&gt; queue = new LinkedBlockingQueue&lt;&gt;(3);<br><br>        // Producer thread<br>        Thread producer = new Thread(() -&gt; {<br>            int itemNumber = 1;<br>            try {<br>                while (true) {<br>                    String item = &quot;Item &quot; + itemNumber++;<br>                    System.out.println(&quot;Producer attempting to add: &quot; + item);<br>                    queue.put(item); // Blocks if the queue is full<br>                    System.out.println(&quot;Producer added: &quot; + item);<br>                    Thread.sleep(500); // Simulate production delay<br>                }<br>            } catch (InterruptedException e) {<br>                Thread.currentThread().interrupt();<br>                System.out.println(&quot;Producer interrupted&quot;);<br>            }<br>        });<br><br>        // Consumer thread<br>        Thread consumer = new Thread(() -&gt; {<br>            try {<br>                while (true) {<br>                    String item = queue.take(); // Blocks if the queue is empty<br>                    System.out.println(&quot;Consumer took: &quot; + item);<br>                    Thread.sleep(1000); // Simulate processing time<br>                }<br>            } catch (InterruptedException e) {<br>                Thread.currentThread().interrupt();<br>                System.out.println(&quot;Consumer interrupted&quot;);<br>            }<br>        });<br><br>        // Start both producer and consumer threads<br>        producer.start();<br>        consumer.start();<br>    }<br>}</pre><p>In the above implementation, we’ve created a <em>LinkedBlockingQueue </em>with a capacity of 3. Therefore, the producer thread blocks if it attempts to put an element once the queue has reached its capacity 3.</p><p>The following code snippet shows the use of <em>LinkedBlockingQueue </em>as an unbounded queue:</p><pre>import java.util.concurrent.BlockingQueue;<br>import java.util.concurrent.LinkedBlockingQueue;<br><br>public class UnboundedQueueExample {<br><br>    public static void main(String[] args) {<br>        // Create an unbounded LinkedBlockingQueue<br>        BlockingQueue&lt;String&gt; queue = new LinkedBlockingQueue&lt;&gt;();<br><br>        // Producer thread<br>        Thread producer = new Thread(() -&gt; {<br>            int itemNumber = 1;<br>            try {<br>                while (true) {<br>                    String item = &quot;Item &quot; + itemNumber++;<br>                    System.out.println(&quot;Producer adding: &quot; + item);<br>                    queue.put(item); // Typically, this will not block because the queue is unbounded<br>                    System.out.println(&quot;Producer added: &quot; + item);<br>                    Thread.sleep(500); // Simulate production delay<br>                }<br>            } catch (InterruptedException e) {<br>                Thread.currentThread().interrupt();<br>                System.out.println(&quot;Producer interrupted&quot;);<br>            }<br>        });<br><br>        // Consumer thread<br>        Thread consumer = new Thread(() -&gt; {<br>            try {<br>                while (true) {<br>                    String item = queue.take(); // Blocks if the queue is empty<br>                    System.out.println(&quot;Consumer took: &quot; + item);<br>                    Thread.sleep(1000); // Simulate processing time<br>                }<br>            } catch (InterruptedException e) {<br>                Thread.currentThread().interrupt();<br>                System.out.println(&quot;Consumer interrupted&quot;);<br>            }<br>        });<br><br>        producer.start();<br>        consumer.start();<br>    }<br>}</pre><p>In the above code snippet, we’ve created an unbounded <em>LinkedBlockingQueue </em>by not specifying any size in the constructor. In this case, the producer thread won’t be blocked as the queue is unbounded. However, if the <em>LinkedBlockingQueue </em>reaches Integre.MAX_VALUE limit, any attempts to put new elements block the producer thread.</p><h4>Summary</h4><p>In this article, we started discussing the BlockingQueue implementations in Java. The following are key takeaways:</p><ol><li>A <em>BlockingQueue </em>implementation adds additional blocking capabilities to a queue in a thread-safe manner. It allows blocking producer threads if the queue is full and also blocking consumer threads if the queue is empty.</li><li>There are several specialized blocking queue implementations available based on capacity and specialised usage.</li><li>A <em>TransferQueue </em>is a special type of <em>BlockingQueue </em>that offers additional capabilities to allow direct handoff of elements between a producer and consumer.</li><li>An <em>ArrayBlockingQueue </em>is a bounded fixed-size blocking queue backed by an array</li><li>A <em>LinkedBlockingQueue </em>is an optionally-bounded blocking queue backed by linked nodes.</li></ol><p>We’ll discuss the remaining <em>BlockingQueue </em>implementations in Part 2 of this article.</p><p>If you are interested, you can read the other articles of this Java Concurrency series available at :</p><ol><li>Article 1: <a href="https://levelup.gitconnected.com/mastering-java-concurrency-core-concepts-and-essentials-6e5291cd324a">Mastering Java Concurrency: Core Concepts and Essentials</a></li><li>Article 2: <a href="https://medium.com/thebackendtech/mastering-java-concurrency-advanced-executors-27de97cbc4bd">Mastering Java Concurrency: Advanced Executors</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abcc6ebffb06" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/mastering-java-concurrency-blocking-queue-implementations-part-1-abcc6ebffb06">Mastering Java Concurrency: Blocking Queue Implementations (Part 1)</a> was originally published in <a href="https://levelup.gitconnected.com">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Java Concurrency: Advanced Executors]]></title>
            <link>https://medium.com/thebackendtech/mastering-java-concurrency-advanced-executors-27de97cbc4bd?source=rss-b7dd955599ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/27de97cbc4bd</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Somnath Musib]]></dc:creator>
            <pubDate>Sat, 02 Nov 2024 21:09:49 GMT</pubDate>
            <atom:updated>2024-11-02T21:09:49.972Z</atom:updated>
            <content:encoded><![CDATA[<h4>A Guide to Using ScheduledExecutorService, ThreadFactory, and ThreadPoolExecutor for Efficient Task Execution</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ifIxdd12yeuv8OWH" /><figcaption><a href="https://unsplash.com/s/photos/jyv%C3%A4skyl%C3%A4%2C-finland">Jyväskylä, Finland</a>, Image Courtesy: Unsplash, <a href="https://unsplash.com/@tommytop">Tommaso Fornoni</a></figcaption></figure><p>In the <a href="https://medium.com/thebackendtech/mastering-java-concurrency-core-concepts-and-essentials-6e5291cd324a">previous article</a>, we talked about some of the core interfaces of the java.util.concurrentpackage. This article will dive into more advanced constructs — <em>ScheduledExecutorService</em>, <em>ThreadFactory</em>, and <em>ThreadPoolExecutor</em>.</p><h4>ScheduledExecutorService</h4><p>This special type of <strong>Executor can schedule tasks to run after a given delay or to execute periodically</strong>. This interface has the following methods:</p><pre><br>public ScheduledFuture&lt;?&gt; schedule(Runnable command,<br>                                   long delay, <br>                                   TimeUnit unit);<br><br>public &lt;V&gt; ScheduledFuture&lt;V&gt; schedule(Callable&lt;V&gt; callable,<br>                                       long delay, <br>                                       TimeUnit unit);<br><br>public ScheduledFuture&lt;?&gt; scheduleAtFixedRate(Runnable command,<br>                                              long initialDelay,<br>                                              long period,<br>                                              TimeUnit unit);<br><br>public ScheduledFuture&lt;?&gt; scheduleWithFixedDelay(Runnable command,<br>                                                 long initialDelay,<br>                                                 long delay,<br>                                                 TimeUnit unit);<br></pre><p>The <em>schedule(..) </em>method schedules a <em>Runnable </em>or <em>Callable </em>to execute after the supplied delay. This is for one-off execution.</p><p>The following example demonstrates the use of <em>ScheduledExecutorService </em>with a <strong>Runnable </strong>implementation with a delay of 1 second.</p><pre>ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);<br>scheduledExecutorService.schedule(() -&gt; System.out.println(&quot;Executed by &quot;+Thread.currentThread().getName()), <br>                                  1, <br>                                  TimeUnit.SECONDS);</pre><p>The following example demonstrates the use of <em>ScheduledExecutorService </em>with a <strong>Callable</strong> implementation with a delay of 1 second.</p><pre>// 1) Create an instance of scheduledExecutorService. In this example, we <br>// are creating a ScheduledThreadPool with 1 thread.<br>ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);<br><br>// 2) Submit an instance of Callable with a delay of 10 seconds.<br>ScheduledFuture&lt;Integer&gt; callableSum = scheduledExecutorService.schedule(() -&gt; {<br>    return IntStream.rangeClosed(1,10).sum();<br>}, 10, TimeUnit.SECONDS);<br><br>System.out.println(&quot;Execution to callableSum is &quot;+(callableSum.isDone() ? &quot;done&quot; : &quot;not done &quot;) +&quot;and has delay of &quot;+callableSum.getDelay(TimeUnit.SECONDS) +&quot; seconds.&quot;);<br>TimeUnit.SECONDS.sleep(3);<br>System.out.println(&quot;Execution to callableSum is &quot;+(callableSum.isDone() ? &quot;done&quot; : &quot;not done &quot;) +&quot;and has delay of &quot;+callableSum.getDelay(TimeUnit.SECONDS) +&quot; seconds.&quot;);<br>int result = callableSum.get();<br>System.out.println(&quot;Execution to callableSum is &quot;+(callableSum.isDone() ? &quot;done &quot; : &quot;not done &quot;) +&quot;and result is &quot;+result);<br><br>scheduledExecutorService.shutdown();</pre><p>The return type of <em>schedule(..)</em> method of the <em>Callable </em>variant is <em>ScheduledFuture</em> which is a special type of <em>Future. </em>The <em>ScheduledFuture </em>adds the capabilities of the <em>Delayed</em> interface which lets us inspect the pending delay of the submitted job.</p><p>The following is the outcome of the above code snippet:</p><pre>Execution to callableSum is not done and has delay of 9 seconds.<br>Execution to callableSum is not done and has delay of 6 seconds.<br>Execution to callableSum is doneand result is 55</pre><p>The <em>scheduleAtFixedRate(..)</em> and <em>scheduleAtFixedDelay(..)</em> lets us schedule tasks that execute periodically. The main difference between these two methods lies in how they execute the task.</p><p>The scheduleAtFixedRate(..) lets us submit a periodic action that becomes enabled first after the given initial delay, and subsequently with the given period; that is, executions will commence after <em>initialDelay </em>then <em>initialDelay + period</em>, then <em>initialDelay + 2 * period</em> and so on.</p><p>Let us see the use of <em>scheduleAtFixedRate(..)</em> in the following example:</p><pre>scheduledExecutorService.scheduleAtFixedRate(() -&gt; System.out.println(&quot;Executing at &quot;+ LocalDateTime.now()), <br>                                              0, <br>                                              3, <br>                                              TimeUnit.SECONDS);</pre><p>In the above code snippet, we are scheduling a task that starts with no initial delay and executes at a rate of 3 seconds. i.e.</p><p>Start at 0 and execute, then run after 3 seconds from the last start time (0+ 1 *3 seconds), next run after 0 + 2*3 seconds and so on.</p><p>The following is the output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*t4oGtrMey3ReGV6iQKm3RQ.png" /><figcaption><em>scheduleAtFixedRate(..) execution</em></figcaption></figure><p>The <em>scheduleAtFixedDelay(..) </em>lets us create a periodic action that becomes enabled first after the given initial delay, and subsequently with the given delay between the termination of one execution and the commencement of the next.</p><p>The following code snippet demonstrates the use of <em>scheduleAtFixedDelay(..)</em></p><pre>scheduledExecutorService.scheduleWithFixedDelay(() -&gt; {<br>            System.out.println(&quot;Executing at &quot;+ LocalTime.now());<br>            try {<br>                TimeUnit.SECONDS.sleep(3);<br>            } catch (InterruptedException e) {<br>                throw new RuntimeException(e);<br>            }<br>        }, 0, 3, TimeUnit.SECONDS);</pre><p>In the above example, we are executing a task with no initial delay and a fixed delay of 3 seconds. The task takes 3 seconds to finish. The following is the outcome:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xLH6-cO30iB9ffF6pLps8A.png" /><figcaption><em>scheduleAtFixedDelay(..) execution</em></figcaption></figure><blockquote>A detailed discussion on the difference between scheduleWithFixedRate and scheduleWithFixedDelay could be found at <a href="https://stackoverflow.com/questions/24649842/scheduleatfixedrate-vs-schedulewithfixeddelay">this StackOverflow</a> link.</blockquote><h4>ThreadFactory</h4><p><strong>A ThreadFactory lets us create a new thread and customize the thread behaviour</strong>. We can provide custom thread name, priority, daemon thread etc. Using this interface removes the need for direct invocation of <em>new Thread().</em></p><p>Let us demonstrate the use of <em>ThreadFactory</em>. We’ll first define our Thread class — <em>AppThread </em>and then define a new <em>ThreadFactory </em>implementation <em>AppThreadFactory </em>that creates new threads.</p><pre>public class AppThread extends Thread {<br><br>   private static final String POOL_DELIMITER = &quot;-&quot;; <br><br>   /**<br>    * Application thread<br>    * <br>    * @param runnable, tasks to be processed<br>    * @param pool, name of the pool<br>    * @param id, Identifier for the thread<br>    */<br>   public AppThread(ThreadGroup group, Runnable runnable, String pool, int id) {<br>      super(group, runnable, String.format(&quot;%s%s%d&quot;, pool+&quot;-thread&quot;, POOL_DELIMITER, id));<br>   }<br><br>}</pre><p>In the above code snippet, we are extending the <em>Thread </em>class to define the custom thread pool name.</p><pre>public class AppThreadFactory implements ThreadFactory{<br><br> private String poolName;<br> private ThreadGroup group;<br><br> private AtomicInteger atomicInteger = new AtomicInteger();<br> <br> public AppThreadFactory(String poolName) {<br>    this.poolName = poolName;<br>    group = Thread.currentThread().getThreadGroup();<br> }<br> <br> @Override<br> public Thread newThread(Runnable runnable) {<br>    Thread appThread = new AppThread(group, runnable, poolName, atomicInteger.incrementAndGet());<br>    if(appThread.isDaemon()) {<br>       appThread.setDaemon(false);<br>    }<br>    if(appThread.getPriority() != Thread.NORM_PRIORITY) {<br>       appThread.setPriority(Thread.NORM_PRIORITY);<br>    }<br>    return appThread;<br>   }<br>}</pre><p>In the above example, we define a custom implementation of the ThreadFactory interface. The <em>AppThreadFactory </em>creates new instances of the <em>AppThread</em> class. It customizes the Daemon property and priority of the generated threads.</p><p>Lastly, let us define an ExecutorService with this <em>AppThreadFactory </em>implementation:</p><pre> ExecutorService executorService = Executors.newFixedThreadPool(2, new AppThreadFactory(&quot;medium-demo&quot;));<br> executorService.execute(() -&gt; {<br>     IntStream.rangeClosed(1,4).forEach((i) -&gt; System.out.println(&quot;Executed by &quot;+Thread.currentThread().getName()));<br> });</pre><p>In the above snippet, we are creating a FixedThreadPool with 2 threads and using the <em>AppThreadFactory</em> implementation. Next, we submit a task to print a few statements to view the thread name.</p><pre>Executed by medium-demo-thread-1<br>Executed by medium-demo-thread-1<br>Executed by medium-demo-thread-1<br>Executed by medium-demo-thread-1</pre><p>The output prints the thread name as customized in the <em>AppThreadFactory.</em></p><h4>ThreadPoolExecutor</h4><p><strong>ThreadPoolExecutor is the thread pool implementation provided in Java.</strong></p><p>Though this class provides the full implementation for a thread pool, programmers often use more specific types of thread pools e.g. <em>FixedThreadPool</em>, <em>CachedThreadPool</em>, <em>SingleThreadExeutor</em>, <em>WorkStealingPool </em>etc, based on the task processing needs. For instance, a <em>FixedThreadPool </em>provides a fixed set of threads for task execution with a <em>LinkedBlockingQueue </em>as a backing queue for task queuing if tasks can not be picked up for immediate processing. This implementation is suitable for good resource optimization.</p><p>Before proceeding further, let us understand how a thread pool internally works. A thread pool executor has the following properties that can be customized:</p><ol><li>Core Pool Size</li><li>Maximum Pool Size</li><li>Keep Alive Time</li><li>A Queue</li><li>A Thread Factory</li><li>Rejection Execution Handler</li></ol><p><strong>Core Pool Size: </strong>This is the minimum number of threads that should be always available in the pool. This is applicable even if there are no active tasks available in the pool for processing. In the event of an abnormal termination of a core pool thread, Java ensures a new thread is created and the core pool size is maintained. However, core pool size threads can be terminated if the <em>allowCoreThreadTimeOut </em>flag is set to true. In this case, core pool threads will be terminated once <em>keepAliveTime </em>expires. The thread pool will have no thread if the pool is inactive and the <em>keepAliveTime </em>expires for all core pool threads.</p><p><strong>Maximum Pool Size: </strong>This is the maximum number of threads that a pool can have and can not go beyond this value.</p><p><strong>Queue: </strong>A queue is used internally to hold the additional tasks once all core pool threads are occupied and not available for new tasks. It is important to note that a new thread is only created if fewer threads are running than the configured number of core poll threads and the job is submitted for processing rather than queuing.</p><p><strong>Thread Factory: </strong>A thread factory is used to create new threads in the thread pool.</p><p><strong>Rejection Execution Handler: </strong>This handler is used to decide when the thread pool is not able to accept new tasks due to various reasons. This includes the max pool size limit that has been reached or the backing queue is full. There are different policies on how to handle tasks that can not be processed by the pool.</p><p>The following example shows the usage of a ThreadPoolExecutor:</p><pre><br> private static final int CORE_POOL_SIZE = 1;<br> private static final int MAX_POOL_SIZE = 2;<br> private static final int KEEP_ALIVE_TIME = 10;<br><br>/** Create a new thread pool executor<br>   *  The minimum number of threads is 1<br>   *  The maximum number of threads is 2<br>   *  Keep alive time for idle thread is 10 seconds<br>   *  The backing queue implementation is an ArrayBlockingQueue with capacity 2<br>   *  The custom thread factory AppThreadFactory is used<br>   *  The RejectedExecutionHandler is CallerRunsPolicy<br>   */<br>  ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(CORE_POOL_SIZE,<br>                  MAX_POOL_SIZE,<br>                  KEEP_ALIVE_TIME,<br>                  TimeUnit.SECONDS,<br>                  new ArrayBlockingQueue&lt;&gt;(1),<br>                  new AppThreadFactory(&quot;medium-demo&quot;),<br>                  new ThreadPoolExecutor.CallerRunsPolicy()<br>                  );<br>  // Prints the executing thread&#39;s name - medium-demo-thread-1<br>  threadPoolExecutor.execute(() -&gt; System.out.println(Thread.currentThread().getName()));</pre><p>Let us explore the use of queue and CallerRunsPolicy a bit more:</p><pre><br> private static final int CORE_POOL_SIZE = 1;<br> private static final int MAX_POOL_SIZE = 2;<br> private static final int KEEP_ALIVE_TIME = 10;<br>    <br> public static void main(String[] args) throws InterruptedException {<br><br><br>    /** Create a new thread pool executor<br>     *  The minimum number of threads is 1<br>     *  The maximum number of threads is 2<br>     *  Keep alive time for idle thread is 10 seconds<br>     *  The backing queue implementation is an ArrayBlockingQueue with capacity 2<br>     *  The custom thread factory AppThreadFactory is used<br>     *  The RejectedExecutionHandler is CallerRunsPolicy<br>     */<br>    ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(CORE_POOL_SIZE,<br>                    MAX_POOL_SIZE,<br>                    KEEP_ALIVE_TIME,<br>                    TimeUnit.SECONDS,<br>                    new ArrayBlockingQueue&lt;&gt;(1),<br>                    new AppThreadFactory(&quot;medium-demo&quot;),<br>                    new ThreadPoolExecutor.CallerRunsPolicy()<br>                    );<br>    // Prints the executing thread&#39;s name - medium-demo-thread-1<br>    threadPoolExecutor.execute(() -&gt; System.out.println(Thread.currentThread().getName()+&quot; executed this task&quot;));<br>  <br>  <br>    // Make the thread sleep so that it is not available for processing<br>    threadPoolExecutor.execute(() -&gt; {<br>     try {<br>      Thread.sleep(500000);<br>     }<br>     catch(InterruptedException ie) {<br>      //<br>     }<br>    });<br>  <br>    // Prints the executing thread&#39;s name - This task is queued.<br>    threadPoolExecutor.execute(() -&gt; System.out.println(Thread.currentThread().getName()+&quot; executed this task&quot;));<br>  <br>    TimeUnit.SECONDS.sleep(2);<br>  <br>    // Remaining capacity is 0 as there is a task already queues. Since the queue size is 1. The queue is now full.<br>    System.out.println(&quot;Remaining queue capacity: &quot;+threadPoolExecutor.getQueue().remainingCapacity());<br>  <br>    /**<br>     *  A new thread is created and put to sleep. At this stage, the max thread pool limit is reached.<br>     *  No new threads can be created.<br>     */<br>    threadPoolExecutor.execute(() -&gt; {<br>     try {<br>      System.out.println(Thread.currentThread().getName() + &quot; is created and going to sleep&quot;);<br>      Thread.sleep(500000);<br>     }<br>     catch (InterruptedException ie) {}<br>    });<br>  <br>    /**<br>     *  This task is executed by the main thread due to CallerRunPolicy.<br>     *  Since both the threads of the pool is occupied and the queue is also full,<br>     *  based on the CallerRunPolicy, Main thread executed the new tasks.<br>     */<br>    threadPoolExecutor.execute(() -&gt; System.out.println(Thread.currentThread().getName()+&quot; thread executed this task&quot;));<br>    threadPoolExecutor.execute(() -&gt; System.out.println(Thread.currentThread().getName()+&quot; thread executed this task&quot;));<br>    threadPoolExecutor.shutdownNow();<br>}</pre><p>The following is the output (Output will vary due to thread scheduling):</p><pre>medium-demo-thread-1 executed this task<br>Remaining queue capacity: 0<br>medium-demo-thread-2 is created and going to sleep<br>main thread executed this task<br>main thread executed this task</pre><h4>Conclusion</h4><p>This article provides an overview of the <em>ScheduledExecutorService, ThreadFactory, </em>and <em>ThreadPoolExecutor.</em></p><p>A <em>ScheduledExecutorService </em>lets us schedule tasks. This scheduling can be one-time or recurring. The schedule, scheduleAtFixedRate, and scheduleAtFixedDelay are the important methods.</p><p>A ThreadFactory lets us create custom threads and removes the need for direct instantiation of the <em>Thread </em>class.</p><p>A <em>ThreadPoolExecutor </em>is a concrete implementation of a thread pool in Java. It provides a rich configuration set to customize the pool properties and their behaviour.</p><p>The source code for this article is available in the following <a href="https://github.com/musibs/Java-Concurrency">GitHub repository</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27de97cbc4bd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/thebackendtech/mastering-java-concurrency-advanced-executors-27de97cbc4bd">Mastering Java Concurrency: Advanced Executors</a> was originally published in <a href="https://medium.com/thebackendtech">The Backend Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hei, Write for Us — The Backend Tech]]></title>
            <link>https://medium.com/thebackendtech/hei-write-for-us-the-backend-tech-825a663b6de6?source=rss-b7dd955599ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/825a663b6de6</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Somnath Musib]]></dc:creator>
            <pubDate>Fri, 01 Nov 2024 02:41:50 GMT</pubDate>
            <atom:updated>2024-11-01T02:41:50.168Z</atom:updated>
            <content:encoded><![CDATA[<h3>Hei, Write for Us — The Backend Tech</h3><h4>Share Your Expertise with the Backend Community — Write for <em>The Backend Tech</em></h4><p><strong>Are you passionate about backend technologies?</strong></p><p>We’re looking for contributors who can share insights on topics such as Java, Spring, Cloud, Databases, API Design, Security, System Design, Scalable Architecture, and anything related to backend technologies.</p><h3>What We’re Looking For:</h3><ul><li><strong>Expertise</strong>: Articles that add value for backend engineers, architects, and tech enthusiasts.</li><li><strong>Topics</strong>: Backend engineering, cloud, databases, security, system design, and emerging trends.</li><li><strong>Quality</strong>: Clear, well-researched, and practical insights that readers can apply.</li></ul><h3>Submission Guidelines:</h3><ul><li><strong>Length</strong>: 800–1500 words.</li><li><strong>Tone</strong>: Professional, clear, and engaging.</li><li><strong>Originality</strong>: Content must be unique and unpublished elsewhere.</li></ul><p>Ready to contribute? Submit your article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=825a663b6de6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/thebackendtech/hei-write-for-us-the-backend-tech-825a663b6de6">Hei, Write for Us — The Backend Tech</a> was originally published in <a href="https://medium.com/thebackendtech">The Backend Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Java Concurrency: Core Concepts and Essentials]]></title>
            <link>https://levelup.gitconnected.com/mastering-java-concurrency-core-concepts-and-essentials-6e5291cd324a?source=rss-b7dd955599ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e5291cd324a</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Somnath Musib]]></dc:creator>
            <pubDate>Fri, 01 Nov 2024 02:06:12 GMT</pubDate>
            <atom:updated>2024-11-07T00:56:17.075Z</atom:updated>
            <content:encoded><![CDATA[<h4>A Deep Dive into Java’s Executor, ExecutorService, Callable, and Future for Effective Multithreading</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*40AqjQKojOc2WIf6" /><figcaption><a href="https://unsplash.com/s/photos/putkilahti%2C-autio%2C-jyv%C3%A4skyl%C3%A4%2C-finland">Putkilahti, Autio, Jyväskylä, Finland</a>, Image Courtesy: Unsplash, <a href="https://unsplash.com/@saltiola7">Tommi Saltiola</a></figcaption></figure><p>One of the core features of Java is the multi-threading and it’s excellent support for<strong> building highly concurrent applications</strong>. JDK 5 and subsequent Java releases have introduced several concurrency constructs that have changed how we think about concurrency in a Java application.</p><p>In this article, we’ll dive into the following major interfaces from the java.util.concurrentpackage:</p><ol><li>Callable</li><li>Future</li><li>Executor</li><li>ExecutorService</li></ol><h4>Callable</h4><p>The <em>Callable</em> interface <strong>represents a task that returns a result or throws an exception</strong>. The following is the definition of this interface:</p><pre>@FunctionalInterface<br>public interface Callable&lt;V&gt; {<br>    /**<br>     * Computes a result, or throws an exception if unable to do so.<br>     *<br>     * @return computed result<br>     * @throws Exception if unable to compute a result<br>     */<br>    V call() throws Exception;<br>}</pre><p>The <em>call()</em> is a no-arg method with a return type of V and can throw the checked exception <em>Exception</em>. Let us demonstrate the use of <em>Callable </em>with an example:</p><pre>class MyCallable implements Callable&lt;Integer&gt; {<br>        @Override<br>        public Integer call() throws Exception {<br>            return IntStream.rangeClosed(1,10).sum();<br>        }<br>    }</pre><p>In the above code snippet, we have written an implementation of the <em>Callable</em> interface called <em>MyCallable. </em>This implementation sums up 1 to 10 and returns the result.</p><p><em>Callable </em>is a functional interface. Therefore, it can be the target of Java 8’s lambda expression. We can rewrite the above code snippet using the following lambda expression:</p><pre>private Callable&lt;Integer&gt; callable = () -&gt; IntStream.rangeClosed(1,10).sum();</pre><h4>Future</h4><p><strong>The <em>Future </em>interface represents the result of an asynchronous computation</strong>. For instance, while we submit a <em>Callable </em>for execution, it returns a <em>Future </em>instance to track the execution status.</p><p><em>Future </em>provides the <em>get(..)</em> method to retrieve the result of the computation or <em>cancel(..)</em> method to cancel the execution. If the result is not yet ready, the <em>get(..)</em> method call is blocked. Further, <em>Future </em>provides the method <em>isCancel()</em> to check whether the task is cancelled before it is completed normally. Similarly, the <em>isDone()</em> lets you check whether the task is completed.</p><p>Let us demonstrate the use of <em>Future </em>in the following example:</p><pre>// Create a Callable task<br>private Callable&lt;Integer&gt; asyncSum = () -&gt; IntStream.rangeClosed(1,10).sum();<br><br>public int runAsyncSum() {<br>    Future&lt;Integer&gt; asyncSumFuture = Executors.newSingleThreadExecutor().submit(asyncSum);<br>    int sum = 0;<br>    try {<br>      sum = asyncSumFuture.get();<br>    } <br>    catch (InterruptedException e) {<br>      throw new RuntimeException(e);<br>    } <br>    catch (ExecutionException e) {<br>      throw new RuntimeException(e);<br>    }<br>    return sum;<br>}</pre><p>In the above code snippet, we are submitting the <em>asyncSum </em>Callable instance to the <em>SingleThreadExecutor</em> for execution. However, since the <em>asyncSum() </em>computation is done asynchronously in a separate thread, the <em>submit()</em> method returns a <em>Future</em> instance. We then call the <em>get() </em>method in the <em>Future </em>instance to retrieve the result.</p><p>The following JUnit test case verifies the result:</p><pre>@Test<br> void testAsyncSum() {<br>     assertThat(new FutureDemo().runAsyncSum()).isEqualTo(55);<br> }</pre><blockquote>In the above example and the subsequent example, I’ve used the Executors.newSingleThreadExecutor() to submit the Callable. We’ll discuss shortly about the Executor and its types. For now, think an executor as something that lets us execute a task asynchronously.</blockquote><p>The <em>Callable </em>is capable of returning exceptions that may occur during the asynchronous computation. This exception is wrapped inside an instance of <em>ExecutionException</em> and returns to the calling code.</p><p>Let us demonstrate this with an example:</p><pre>private Callable&lt;Integer&gt; asyncDivideByZero = () -&gt; 1/0;<br><br>public void runAsyncDivideByZero() throws ExecutionException {<br>    Future&lt;Integer&gt; asyncDivideByZeroFuture = Executors.newSingleThreadExecutor().submit(asyncDivideByZero);<br>    try {<br>        asyncDivideByZeroFuture.get();<br>    } <br>    catch (InterruptedException e) {<br>        throw new RuntimeException(e);<br>    } <br>    catch (ExecutionException e) {<br>        throw e;<br>    }<br>}</pre><p>In the above code snippet, we’ve defined a <em>Callable </em>instance that returns a <em>RuntimeException </em>at execution. This exception is wrapped in an <em>ExecutionException </em>and returned to the caller.</p><p>The following JUnit test case validates this:</p><pre>@Test<br>void testAsyncDivideByZero() {<br>    assertThatExceptionOfType(ExecutionException.class)<br>        .isThrownBy(new FutureDemo()::runAsyncDivideByZero)<br>        .withMessageContaining(&quot;/ by zero&quot;);<br>}</pre><p>Let us demonstrate the use of <em>isDone()</em>, <em>cancel()</em> and <em>isCancelled()</em> methods as well.</p><pre>private Callable&lt;Integer&gt; delayedTask  = () -&gt; {<br>    TimeUnit.SECONDS.sleep(50);<br>    return 0;<br>};<br><br>public Future&lt;Integer&gt; callDelayedTask() throws ExecutionException {<br>    return Executors.newSingleThreadExecutor().submit(delayedTask);<br>}</pre><p>In the above code snippet, we have defined a task that makes the calling thread sleep for 50 seconds. We then submit this task to an executor.</p><pre>@Test<br>void testDelayedTaskIsNotDone() throws ExecutionException {<br>    assertThat(new FutureDemo().callDelayedTask()).isNotDone();<br>}</pre><p>The above test case asserts that the task is not done. This returns true as the task waits for 50 seconds and is not yet done.</p><pre>@Test<br>void testDelayedTaskIsCancelled() throws ExecutionException {<br>    Future&lt;Integer&gt; future = new FutureDemo().callDelayedTask();<br>    future.cancel(true);<br>    assertThat(future).isCancelled();<br>}</pre><p>In the above test case, we cancel the task and assert that it is cancelled.</p><h4>Executor</h4><p>The <em>Executor </em>is the simplest interface in the executor framework. It <strong>provides a method for executing tasks by accepting an instance of <em>Runnable </em>and running it</strong>. This interface serves as the foundation for more advanced executor types.</p><p>The following is the definition of this interface:</p><pre>public interface Executor {<br><br>/**<br>     * Executes the given command at some time in the future.  The command<br>     * may execute in a new thread, in a pooled thread, or in the calling<br>     * thread, at the discretion of the {@code Executor} implementation.<br>     *<br>     * @param command the runnable task<br>     * @throws RejectedExecutionException if this task cannot be<br>     * accepted for execution<br>     * @throws NullPointerException if command is null<br>     */<br>    void execute(Runnable command);<br>}</pre><p>Though most basic, this interface provides the foundation and represents the notion of execution. It provides a mechanism to decouple the task submission from the task execution and other aspects such as thread creation, scheduling etc.</p><p>The following example demonstrates the usage of the Executor interface:</p><pre>class MainThreadExecutor implements Executor {<br>    @Override<br>    public void execute(Runnable command) {<br>        command.run();<br>    }<br>} <br><br>class ThreadPerTaskExecutor implements Executor {<br>    @Override<br>    public void execute(Runnable command) {<br>        new Thread(command).start();<br>    }<br>}</pre><p>I’ve provided two examples — the <em>MainThreadExecutor </em>implementation executes the tasks in the same Main thread. The <em>ThreadPerTaskExecutor </em>implementation creates a new thread for each task.</p><p>Let us now use these executors to submit some tasks:</p><pre>public static void main(String[] args) {<br>    new MainThreadExecutor().execute(() -&gt; System.out.println(&quot;Executed by &quot;+Thread.currentThread().getName() + &quot; Thread&quot;));<br>    new ThreadPerTaskExecutor().execute(() -&gt; System.out.println(&quot;Executed by &quot;+Thread.currentThread().getName() + &quot; Thread&quot;));<br>    new ThreadPerTaskExecutor().execute(() -&gt; System.out.println(&quot;Executed by &quot;+Thread.currentThread().getName() + &quot; Thread&quot;));<br>}</pre><p>The above code snippet prints the following messages:</p><pre>Executed by main Thread<br>Executed by Thread-0 Thread<br>Executed by Thread-1 Thread</pre><p>The <em>MainThreadExecutor </em>uses the Main thread, so it prints the “main Thread”. The ThreadPerTaskExecutor uses a different thread for each task. Hence, it prints “Thread-0 Thread” and “Thread-1 Thread” which are the thread names executing the task.</p><h4>ExecutorService</h4><p><em>ExecutorService </em>interface extends the Executor interface by adding the following additional capabilities:</p><ol><li>Include<strong> methods to manage the termination of the executor</strong>.</li><li>Provide <strong>methods that produce Future for tracking the execution of the submitted tasks</strong>.</li></ol><p><em>ExecutorService </em>offers the following methods to manage the executor’s termination:</p><p><strong>shutdown()</strong> — Invoking this method initiates an orderly shutdown of the executor. It allows the submitted tasks to be completed but does not accept any new tasks.</p><p><strong>shutdownNow()</strong> — Invoking this method attempts to terminate the executor immediately, including terminating the in-progress executing tasks. It return the list of tasks that were awaiting execution.</p><p><strong>awaitTermination(long timeout, TimeUnit unit)</strong> — This method blocks until all tasks have completed execution after a shutdown request, the timeout occurs, or the current thread is interrupted, whichever happens first.</p><p><em>ExectorService </em>also provides methods to submit tasks to it and returns Future instances to track their execution status. You can submit tasks one after another or bulk submit them.</p><p>The <em>submit(..)</em> methods allow you to submit either a Runnable or Callable task. The <em>invokeAll(..)</em> and <em>invokeAny()</em> let us submit a collection of jobs. The <em>invokeAll(..), </em>for instance, executes all the jobs submitted to it. The <em>invokeAny() </em>executes the tasks and returns the result of any of the jobs that is successfully completed.</p><p>The following example demonstrates the usage of the <em>ExecutorService.</em></p><pre>public class ExecutorServiceDemo {<br><br>public static void main(String... args) throws InterruptedException {<br><br>        // 1) Create an instance of ExecutorService. We are using a <br>        // SingleThreadExecutor instance<br>        ExecutorService executorService = Executors.newSingleThreadExecutor();<br>        <br>        // 2) Create a list of Callable<br>        List&lt;Callable&lt;Void&gt;&gt; callableList = IntStream.rangeClosed(1, 30)<br>                .mapToObj(ExecutorServiceDemo::createTask)<br>                .collect(Collectors.toList());<br>        <br>        // 3) Invoke all the Callables<br>        executorService.invokeAll(callableList);<br>        <br>        // 4) Shutdown the ExecutorService<br>        executorService.shutdown();<br>        <br>        // 5) Allow maximum 10 seconds to complete the tasks<br>        if (!executorService.awaitTermination(10, TimeUnit.SECONDS)) {<br>            System.out.println(&quot;Pool did not shut down within the timeout.&quot;);<br>        } <br>        else {<br>            System.out.println(&quot;Pool shut down successfully.&quot;);<br>        }<br>    }<br><br><br>    private static Callable&lt;Void&gt; createTask(int i) {<br>        return () -&gt; {<br>            System.out.println(&quot;Task &quot;+i+&quot; is completed&quot;);<br>            return null;<br>        };<br>    }<br>}</pre><h4>Conclusion</h4><p>In this article, we discussed some of the foundational interfaces from the Java concurrency package.</p><p>To summarize, <strong><em>Callable </em></strong>is a functional interface that represents a task that can return a result or throw an exception, allowing for flexible, concurrent computations.</p><p>A <strong><em>Future </em></strong>is a placeholder for the result of an asynchronous task that allows retrieval of the result once the computation is complete, including cancellation support.</p><p>An <strong><em>Executor </em></strong>is an interface that provides a way to execute tasks asynchronously without directly managing threads.</p><p>Lastly, an <strong><em>ExecutorService </em></strong>is an Executor that allows task scheduling, termination, and advanced management of asynchronous tasks in a controlled thread pool.</p><p>In the next article, I’ll cover the use of <em>ScheduledExecutorService</em>, <em>ThreadFactory</em>, and <em>ThreadPoolExecutor</em>.</p><p>The source code for this article is available in the following <a href="https://github.com/musibs/Java-Concurrency">GitHub repository</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e5291cd324a" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/mastering-java-concurrency-core-concepts-and-essentials-6e5291cd324a">Mastering Java Concurrency: Core Concepts and Essentials</a> was originally published in <a href="https://levelup.gitconnected.com">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Spring Security 6.3’s JDK Serialization Support]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://musibs.medium.com/exploring-spring-security-6-3s-jdk-serialization-support-d4062a3d935c?source=rss-b7dd955599ca------2"><img src="https://cdn-images-1.medium.com/max/2188/0*LPFnvte6uahxA0Br" width="2188"></a></p><p class="medium-feed-snippet">Enhanced Compatibility and Secure JDK Serialization</p><p class="medium-feed-link"><a href="https://musibs.medium.com/exploring-spring-security-6-3s-jdk-serialization-support-d4062a3d935c?source=rss-b7dd955599ca------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://musibs.medium.com/exploring-spring-security-6-3s-jdk-serialization-support-d4062a3d935c?source=rss-b7dd955599ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4062a3d935c</guid>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Somnath Musib]]></dc:creator>
            <pubDate>Tue, 29 Oct 2024 20:15:33 GMT</pubDate>
            <atom:updated>2024-10-29T20:15:33.552Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How to Write Clean Code with Record Patterns in Java 21]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/javarevisited/how-to-write-clean-code-with-record-patterns-in-java-21-7519ab81f600?source=rss-b7dd955599ca------2"><img src="https://cdn-images-1.medium.com/max/2600/1*_iu2slef-dfRHVjhEz0ZDA.jpeg" width="6016"></a></p><p class="medium-feed-snippet">Java Introduced record type in Java 14. In version 21, Java introduced record patterns that de-structures the instances of record classes&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/javarevisited/how-to-write-clean-code-with-record-patterns-in-java-21-7519ab81f600?source=rss-b7dd955599ca------2">Continue reading on Javarevisited »</a></p></div>]]></description>
            <link>https://medium.com/javarevisited/how-to-write-clean-code-with-record-patterns-in-java-21-7519ab81f600?source=rss-b7dd955599ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/7519ab81f600</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Somnath Musib]]></dc:creator>
            <pubDate>Mon, 01 Jan 2024 15:30:21 GMT</pubDate>
            <atom:updated>2024-01-01T15:30:21.727Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Six Newly Introduced Features of Spring Boot 3.0]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/javarevisited/six-newly-introduced-features-of-spring-boot-3-0-74c6fbdf41c0?source=rss-b7dd955599ca------2"><img src="https://cdn-images-1.medium.com/max/1000/0*iFxVrHJdqFUn7vKI" width="1000"></a></p><p class="medium-feed-snippet">A Summary of changes introduced/updated in Spring Boot 3.0 that you should be aware of.</p><p class="medium-feed-link"><a href="https://medium.com/javarevisited/six-newly-introduced-features-of-spring-boot-3-0-74c6fbdf41c0?source=rss-b7dd955599ca------2">Continue reading on Javarevisited »</a></p></div>]]></description>
            <link>https://medium.com/javarevisited/six-newly-introduced-features-of-spring-boot-3-0-74c6fbdf41c0?source=rss-b7dd955599ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/74c6fbdf41c0</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Somnath Musib]]></dc:creator>
            <pubDate>Mon, 06 Mar 2023 15:47:00 GMT</pubDate>
            <atom:updated>2023-03-06T15:47:00.134Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Real time data sync across S3 buckets with Amazon EventBridge and AWS Step Functions]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://levelup.gitconnected.com/real-time-data-sync-in-s3-buckets-with-amazon-eventbridge-and-aws-step-functions-ff0fdda1933?source=rss-b7dd955599ca------2"><img src="https://cdn-images-1.medium.com/max/893/1*KkxpEVb6jF9jgMpfkDXzKA.png" width="893"></a></p><p class="medium-feed-snippet">In this article, we&#x2019;ll discuss how to replicate data from one S3 bucket to another S3 bucket in real time with Amazon EventBridge and AWS&#x2026;</p><p class="medium-feed-link"><a href="https://levelup.gitconnected.com/real-time-data-sync-in-s3-buckets-with-amazon-eventbridge-and-aws-step-functions-ff0fdda1933?source=rss-b7dd955599ca------2">Continue reading on Level Up Coding »</a></p></div>]]></description>
            <link>https://levelup.gitconnected.com/real-time-data-sync-in-s3-buckets-with-amazon-eventbridge-and-aws-step-functions-ff0fdda1933?source=rss-b7dd955599ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff0fdda1933</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[architecture]]></category>
            <dc:creator><![CDATA[Somnath Musib]]></dc:creator>
            <pubDate>Mon, 06 Feb 2023 20:39:15 GMT</pubDate>
            <atom:updated>2023-02-07T14:05:33.054Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Setting up Kafka Mirror Maker for Kafka Topic Replication]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/javarevisited/setting-up-kafka-mirror-maker-for-kafka-topic-replication-a6dc5417b718?source=rss-b7dd955599ca------2"><img src="https://cdn-images-1.medium.com/max/1000/0*JQSxsQ0nd0gzBhZL" width="1000"></a></p><p class="medium-feed-snippet">Apache Kafka Mirror Maker 2 assists to replicate topics across Kafka clusters</p><p class="medium-feed-link"><a href="https://medium.com/javarevisited/setting-up-kafka-mirror-maker-for-kafka-topic-replication-a6dc5417b718?source=rss-b7dd955599ca------2">Continue reading on Javarevisited »</a></p></div>]]></description>
            <link>https://medium.com/javarevisited/setting-up-kafka-mirror-maker-for-kafka-topic-replication-a6dc5417b718?source=rss-b7dd955599ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6dc5417b718</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <dc:creator><![CDATA[Somnath Musib]]></dc:creator>
            <pubDate>Sun, 06 Nov 2022 17:15:47 GMT</pubDate>
            <atom:updated>2024-01-09T15:21:50.156Z</atom:updated>
        </item>
    </channel>
</rss>