We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
大部分情况下使用递归锁是一种很糟糕的选择。
https://mthli.xyz/recursive-re-entrant-locks/
The text was updated successfully, but these errors were encountered:
当你在阅读代码时,获取锁和释放锁是语义上的屏障。我们可以很自然地假设当锁被释放时不变量仍然保持不变,但在递归锁场景下这种假设并不成立。当 B 调用 A 时,A 并不能确定获取锁时不变量保持不变,也不能确定释放锁时不变量保持不变。
这里怎么理解? 递归锁不是一个线程重复获取锁的过程吗? 如果是一个线程,为什么不能保证变量操作的原子性?
Sorry, something went wrong.
No branches or pull requests
递归锁的缺点
大部分情况下使用递归锁是一种很糟糕的选择。
https://mthli.xyz/recursive-re-entrant-locks/
The text was updated successfully, but these errors were encountered: