GO RLock产生的死锁问题

func f1() {
    l.RLock()//lock 1
    defer l.RUnlock() //
   
    //2.thread_b()获取写 写必须等待lock 1释放
    
    l.RLock() //这里又申请读 读 必须等待 thread_b()写锁释放 而thread_b等待该线程释放锁
    defer l.RUnlock()
}
 
 
 
 func thread_b() {
    l.Lock()
    defer l.Unlock() 
    //等待 lock 1释放
    
}

 

发表评论

邮箱地址不会被公开。 必填项已用*标注