<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Mutex on rustbites</title><link>https://www.rustbites.com/tags/mutex/</link><description>Recent content in Mutex on rustbites</description><generator>Hugo</generator><language>en</language><lastBuildDate>Fri, 22 May 2026 10:47:41 +0200</lastBuildDate><atom:link href="https://www.rustbites.com/tags/mutex/index.xml" rel="self" type="application/rss+xml"/><item><title>155. Mutex&lt;T&gt; — Cross-Thread Exclusive Access, With a Guard Instead of a Panic</title><link>https://www.rustbites.com/posts/bite-155/</link><pubDate>Fri, 22 May 2026 09:00:00 +0100</pubDate><guid>https://www.rustbites.com/posts/bite-155/</guid><description>&lt;p&gt;Yesterday&amp;rsquo;s &lt;a href="https://www.rustbites.com/posts/bite-152/"&gt;RefCell&amp;lt;T&amp;gt;&lt;/a&gt; gives you &lt;code&gt;&amp;amp;mut&lt;/code&gt; through &lt;code&gt;&amp;amp;self&lt;/code&gt; on a single thread — and panics the moment a second borrow shows up. &lt;code&gt;Mutex&amp;lt;T&amp;gt;&lt;/code&gt; is the same idea wearing a hard hat: it&amp;rsquo;s &lt;code&gt;Sync&lt;/code&gt;, so it works across threads, and instead of panicking on contention it just &lt;em&gt;blocks&lt;/em&gt; until the other holder is done.&lt;/p&gt;</description></item></channel></rss>