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

功能性严重bug #5

Open
wu560130911 opened this issue Apr 3, 2018 · 5 comments
Open

功能性严重bug #5

wu560130911 opened this issue Apr 3, 2018 · 5 comments

Comments

@wu560130911
Copy link

wu560130911 commented Apr 3, 2018

https://github.com/zhuzhong/idleaf/blob/master/src/main/java/com/zhuzhong/idleaf/support/MysqlIdLeafServiceImpl.java
此类实现存在严重功能性bug。
1、ReentrantLock为什么定义成静态的?全局共用一把锁?
2、AtomicLong的引用经常被改变,多线程读取的时候确定没有问题?
3、currentId.longValue()无法保证多线程下,不同代码行拿到的数据一致性。

@optor666
Copy link

optor666 commented Aug 24, 2018

1、ReentrantLock为什么定义成静态的?全局共用一把锁?

这个确实是问题

2、AtomicLong的引用经常被改变,多线程读取的时候确定没有问题?

我看 AtomicLong currentId 引用被改变时都是在锁内,应该没问题吧

3、currentId.longValue()无法保证多线程下,不同代码行拿到的数据一致性。

原子类多线程下拿到的数据是一致的吧
最后,这代码作者是不是已经不维护了,刚才下载下来看了看感觉有点乱 😔

@wu560130911
Copy link
Author

看这个版本吧,高并发场景下实践过的。
https://github.com/wu560130911/idleaf

@zhuzhong
Copy link
Owner

ok,@wu560130911 参照你的版本我已将其进行升级

@zhuzhong
Copy link
Owner

@wu560130911 你的同步版本中,当达到50%之后每次都需要获取锁,可考虑再优化一下

@wu560130911
Copy link
Author

@zhuzhong 优化过的,只有两种情况才会进去啊

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

3 participants