<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Multithreading on Java &amp; Software Architecture Knowledge Hub</title><link>https://samirsahoo.github.io/design-patterns-hub/tags/multithreading/</link><description>Recent content in Multithreading on Java &amp; Software Architecture Knowledge Hub</description><generator>Hugo</generator><language>en-US</language><copyright>© 2026 Samir Kumar Sahoo (https://github.com/samirsahoo). All rights reserved.</copyright><atom:link href="https://samirsahoo.github.io/design-patterns-hub/tags/multithreading/index.xml" rel="self" type="application/rss+xml"/><item><title>The Java Concurrency API: Executors, CompletableFuture, Locks and Concurrent Collections</title><link>https://samirsahoo.github.io/design-patterns-hub/java/advanced/concurrency-api/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/java/advanced/concurrency-api/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;&lt;code&gt;java.util.concurrent&lt;/code&gt; provides &lt;strong&gt;higher-level building blocks&lt;/strong&gt; for running work in parallel and coordinating threads safely:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;executors&lt;/strong&gt; run tasks&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;futures&lt;/strong&gt; represent results that arrive later&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;locks and atomics&lt;/strong&gt; protect shared state&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;concurrent collections&lt;/strong&gt; are safe to share between threads.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="the-problem"&gt;The problem&lt;a class="heading-anchor" href="#the-problem" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Creating raw &lt;code&gt;Thread&lt;/code&gt;s per task does not scale (platform threads are expensive OS threads). Hand-written &lt;code&gt;wait&lt;/code&gt;/&lt;code&gt;notify&lt;/code&gt; code is notoriously buggy. Sharing a plain &lt;code&gt;HashMap&lt;/code&gt; between threads corrupts it. The concurrency API gives tested abstractions, so you rarely touch low-level primitives.&lt;/p&gt;</description></item></channel></rss>