Foundation of Go Language —— 12. Mutex (Not translated)
»
    Go语言中类似C++,在Go语言的sync包中有同步锁RWMuteximport (
        "sync"
    )

    var lock sync.RWMutex
    var age int

    func addYear(){
        lock.RLock()
        defer lock.Unlock()//defer,延迟执行,在函数返回之前执行
        age = age + 1
    }

    ————www.v-signon.com学习者共勉
                        
«
--Alex.Zhang
--www.v-signon.com Learningers Co-Encouraged
Back
Personal Art: www.up-task.com Unit: Individual
中文 Русский 京ICP备19038994号-2
If the content on this website infringes upon your any rights, please contact me at 1307776259@qq.com for removal