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