<?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 Golang</title><link>https://golang.k5kc.com/tags/mutex/</link><description>Recent content in mutex on Golang</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Sun, 16 Aug 2020 00:14:00 +0530</lastBuildDate><atom:link href="https://golang.k5kc.com/tags/mutex/index.xml" rel="self" type="application/rss+xml"/><item><title>Mutex - Mutual Exclusion Lock</title><link>https://golang.k5kc.com/2020/08/16/5.mutex/</link><pubDate>Sun, 16 Aug 2020 00:14:00 +0530</pubDate><guid>https://golang.k5kc.com/2020/08/16/5.mutex/</guid><description>Intro Mutexes let you synchronize data access by explicit locking, without channels. Sometimes it’s more convenient to synchronize data access by explicit locking instead of using channels. The Go standard library offers a mutual exclusion lock, sync.Mutex, for this purpose.
Example - Basic usage Here&amp;rsquo;s a basic example illustrating Lock and Unlock:
func main() { mutex := sync.Mutex{} mutex.Lock() go func() { mutex.Lock() // Wait for main to call Unlock fmt.</description></item></channel></rss>