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

LockContext map Concurrent Question #553

Open
1 task
Micheal-Bigmac opened this issue Sep 29, 2020 · 1 comment
Open
1 task

LockContext map Concurrent Question #553

Micheal-Bigmac opened this issue Sep 29, 2020 · 1 comment

Comments

@Micheal-Bigmac
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

1. Bug Description

LockContext
private Map<String, Lock> map;
private LockContext() {
map = new ConcurrentHashMap<>();

    cacheList = new CopyOnWriteArrayList<>();

    freeList = new LinkedList<>();
}

map is ConcurrentHashMap 但是你在操作这个元素时 加锁防止脏读,污写 ,完全没必要了

4. Tour Idea

既然是ConcurrentHashMap 完全可以把synchronized 锁去掉,而且不会脏读,重复添加, 这样做牺牲性能了

@Micheal-Bigmac
Copy link
Author

Micheal-Bigmac commented Sep 29, 2020

这个类 写的很不友好

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