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

加锁吗? #10

Open
lzb200244 opened this issue Nov 29, 2023 · 1 comment
Open

加锁吗? #10

lzb200244 opened this issue Nov 29, 2023 · 1 comment

Comments

@lzb200244
Copy link


p.RLock()
current := atomic.LoadInt32(&p.current)
p.RUnlock()

请问一下,使用了atomic为什么还需要加锁?加锁和原子化是不是其中有一个多余了呢?

@elbert-chan
Copy link


p.RLock()
current := atomic.LoadInt32(&p.current)
p.RUnlock()

请问一下,使用了atomic为什么还需要加锁?加锁和原子化是不是其中有一个多余了呢?

这个锁确实没必要。

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

2 participants