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 use of volatile #2

Open
syedfaisal3 opened this issue Feb 13, 2023 · 0 comments
Open

Unnecessary use of volatile #2

syedfaisal3 opened this issue Feb 13, 2023 · 0 comments

Comments

@syedfaisal3
Copy link

@callicoder The entire nextId() method is synchronized! Why do we need a volatile still?

private volatile long lastTimestamp = -1L;
private volatile long sequence = 0L;

public synchronized long nextId() {
}

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