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

Unnecessary synchronisation? #1573

Open
sebbASF opened this issue Dec 5, 2023 · 1 comment
Open

Unnecessary synchronisation? #1573

sebbASF opened this issue Dec 5, 2023 · 1 comment

Comments

@sebbASF
Copy link

sebbASF commented Dec 5, 2023

private synchronized CleanerRef add(CleanerRef ref) {
synchronized (referenceQueue) {

private synchronized boolean remove(CleanerRef ref) {
synchronized (referenceQueue) {

The entire body of both methods is part of the synch. block, so it seems unnecessary to synch the method as well.

@matthiasblaesing
Copy link
Member

That might be, given that there we are already hitting the slow path (synchronized), I currently have no cycles to look into something that does not seriously effect performance, so if someone wants to change this, can make it clear, that it is safe and show numbers over JDK 8-21 that this is a problem, I'm willing to review.

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