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

设计不合理 #42

Open
huzhihong opened this issue Sep 20, 2019 · 2 comments
Open

设计不合理 #42

huzhihong opened this issue Sep 20, 2019 · 2 comments

Comments

@huzhihong
Copy link

image
使用的是固定大小线程池,可是给线程池提交的任务的时候又特意控制并发,转为单线程。
image
我觉得没必要这样设置,直接使用一个线程就行了,或者不要控制并发,提高生成速度。

@wsiner
Copy link

wsiner commented Jul 10, 2020

确实用单线程就好了,这个就是强行使用多线程,二图的写法 是为了执行 ringBuffer.put(uid)的时候,保证uid有序的存到RingBuffer的slots属性里面,不这么写就不能保证客户端取出来的值是递增的

@dugreen
Copy link

dugreen commented Nov 7, 2023

我也有同样的疑问,那这里的 sync 也就可以去掉了:

    RingBuffer
    public synchronized boolean put(long uid) {
    }

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