<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Race-Conditions on Rafiul Alam</title>
    <link>https://alamrafiul.com/tags/race-conditions/</link>
    <description>Recent content in Race-Conditions on Rafiul Alam</description>
    <image>
      <title>Rafiul Alam</title>
      <url>https://alamrafiul.com/papermod-cover.png</url>
      <link>https://alamrafiul.com/papermod-cover.png</link>
    </image>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Wed, 05 Feb 2025 00:00:00 +0000</lastBuildDate><atom:link href="https://alamrafiul.com/tags/race-conditions/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Go Concurrency Pattern: The Ticket Seller</title>
      <link>https://alamrafiul.com/posts/go-ticket-seller/</link>
      <pubDate>Wed, 05 Feb 2025 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/posts/go-ticket-seller/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://alamrafiul.com/posts/go-bank-account-drama/&#34;&gt;← Bank Account Drama&lt;/a&gt; | &lt;a href=&#34;https://alamrafiul.com/concurrency-patterns/&#34;&gt;Series Overview&lt;/a&gt; | &lt;a href=&#34;https://alamrafiul.com/posts/go-login-counter/&#34;&gt;Login Counter →&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;the-problem-selling-tickets-that-dont-exist&#34;&gt;The Problem: Selling Tickets That Don&amp;rsquo;t Exist&lt;/h2&gt;
&lt;p&gt;A concert has 1,000 tickets. Multiple goroutines handle sales concurrently. Each seller checks if tickets remain, and if yes, decrements the count and sells one. Sounds simple, right?&lt;/p&gt;
&lt;p&gt;Two sellers check simultaneously. Both see &amp;ldquo;1 ticket remaining.&amp;rdquo; Both sell. You&amp;rsquo;ve just sold ticket number -1. Congratulations, you&amp;rsquo;ve discovered the &lt;strong&gt;check-then-act&lt;/strong&gt; race condition, one of the most common concurrency bugs in the wild.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Go Concurrency Pattern: The Bank Account Drama</title>
      <link>https://alamrafiul.com/posts/go-bank-account-drama/</link>
      <pubDate>Sat, 18 Jan 2025 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/posts/go-bank-account-drama/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://alamrafiul.com/posts/go-login-counter/&#34;&gt;← Login Counter&lt;/a&gt; | &lt;a href=&#34;https://alamrafiul.com/concurrency-patterns/&#34;&gt;Series Overview&lt;/a&gt; | &lt;a href=&#34;https://alamrafiul.com/posts/go-ticket-seller/&#34;&gt;Ticket Seller →&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;the-problem-money-vanishing-into-thin-air&#34;&gt;The Problem: Money Vanishing Into Thin Air&lt;/h2&gt;
&lt;p&gt;Two people share a bank account with $100. Both check the balance at the same time, see $100, and both withdraw $100. The bank just lost $100. This isn&amp;rsquo;t a hypothetical-race conditions in financial systems have caused real monetary losses.&lt;/p&gt;
&lt;p&gt;The bank account drama illustrates the fundamental challenge of concurrent programming: &lt;strong&gt;read-modify-write operations are not atomic&lt;/strong&gt;. What seems like a simple operation actually involves multiple steps, and when multiple goroutines execute these steps concurrently, chaos ensues.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Go Memory Model Explained</title>
      <link>https://alamrafiul.com/posts/go-memory-model/</link>
      <pubDate>Tue, 25 Jun 2024 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/posts/go-memory-model/</guid>
      <description>Deep dive into Go&amp;#39;s memory model, happens-before relationships, memory visibility guarantees, and what really happens with goroutines and shared memory.</description>
    </item>
    
  </channel>
</rss>
