【摘要】sync.Mutex 互斥锁 一、为什么需要互斥锁 当多个 goroutine 同时读写同一个变量时,会发生数据竞争(data race)。比如银行账户的例子: var balance int func Deposit(amount int) { balance = balance + amount 阅读全文