<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Sync on Cheat Sheet</title><link>/tags/sync/</link><description>Recent content in Sync on Cheat Sheet</description><generator>Hugo</generator><language>en</language><atom:link href="/tags/sync/index.xml" rel="self" type="application/rss+xml"/><item><title>sync</title><link>/programming/go/concurrency/sync/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/programming/go/concurrency/sync/</guid><description>&lt;h1 id="sync"&gt;&lt;code&gt;sync&lt;/code&gt;&lt;a class="anchor" href="#sync"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Go&amp;rsquo;s &lt;code&gt;sync&lt;/code&gt; package is based on &lt;strong&gt;synchronizing by sharing memory&lt;/strong&gt;, providing low-level primitives for memory-access synchronization and critical section protection among goroutines. Unlike channels, which share memory by communicating, &lt;code&gt;sync&lt;/code&gt; deals with traditional locking and signaling primitives.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="1-syncwaitgroup"&gt;1. &lt;code&gt;sync.WaitGroup&lt;/code&gt;&lt;a class="anchor" href="#1-syncwaitgroup"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Used to establish a &lt;strong&gt;Join Point&lt;/strong&gt; waiting for the completion of concurrent branches in Go&amp;rsquo;s &lt;a href="../../cs/concurrency-and-parallelism/concepts/#51-dimension-1-rendezvous-vs-fork-join-lifecycle--synchronization"&gt;Fork-Join model&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For single goroutine cancellation or waiting, &lt;a href="../../programming/go/std/context/"&gt;context cancellation&lt;/a&gt; is preferred, but &lt;code&gt;WaitGroup&lt;/code&gt; is the standard tool for waiting on multiple concurrent tasks.&lt;/p&gt;</description></item></channel></rss>