Skip to content
New issue

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

读阻塞且并发安全的 Map,答案是否有问题? #66

Open
CraigMChen opened this issue Oct 13, 2022 · 0 comments
Open

读阻塞且并发安全的 Map,答案是否有问题? #66

CraigMChen opened this issue Oct 13, 2022 · 0 comments

Comments

@CraigMChen
Copy link

m.rmx.RUnlock()

m.rmx.Lock()

这两行代码中的解锁和加锁操作并不是原子的,在 57 行解锁后,锁可能会被其他协程拿到。如果锁被一个写操作的协程拿到,就会出现刚写入的键值对又被覆盖成空的情况。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant