摘要: 相比于Mutex来说,RWMutex锁的粒度更细,使用RWMutex可以并发读,但是不能并发读写,或者写写。 1. sync.RWMutex的结构 type RWMutex struct { // 互斥锁 w Mutex // held if there are pending writers // 阅读全文
posted @ 2021-04-28 18:23 卷毛狒狒 阅读(76) 评论(0) 推荐(0) 编辑
摘要: Mutex是go标准库中的互斥锁,用于处理并发场景下共享资源的访问冲突问题。 1. Mutex定义: // A Mutex is a mutual exclusion lock. // The zero value for a Mutex is an unlocked mutex. // // A 阅读全文
posted @ 2021-04-28 16:01 卷毛狒狒 阅读(103) 评论(0) 推荐(0) 编辑