Skip to content

Unnecessary use of volatile #2

Open
@syedfaisal3

Description

@syedfaisal3

@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() {
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions