Deep Understanding of Golang Mutex

How to implement Golang Mutex

Dwen
Level Up Coding
Published in
12 min readSep 22, 2022

--

Photo by Daniil Silantev on Unsplash

Before we start, we need to add several ways to implement locks.

# Semaphore.

There are P and V operations in the OS. The P operation is to change the semaphore by -1, and the V operation is to increase the semaphore by 1, so the operation mode of the semaphore is:

--

--

I'm an independent entrepreneur, a developer and a father, enjoys speaking, writing, and sharing.