登录
sync.Mutex
已收录文章:1篇
三天内
三天内
一周内
一月内
三月内
最新
最热
Golang
·
Go教程
| 2年前 |
sync.Mutex
·
golang
golang中sync.Mutex的实现方法
mutex 的实现思想 mutex 主要有两个 method: Lock() 和 Unlock() Lock() 可以通过一个 CAS 操作来实现 func (m *Mutex) Lock() { for !atomic.CompareAndSwapUint32(&m.locked, 0, 1) { } } func (m *Mutex) Unlock() { a
282
收藏