public State withNextSequenceNo() {
            if (sequenceNo < MAX_SEQUENCE_NO) {
                return new State(epochMs, sequenceNo + 1);
            } else {
                // Overflowed sequenceNo so wait for the next epochMs to roll round.
                // Very unlikely for us to need more than 10k IDs in a millisecond on
                // one node.
                long newEpochMs = System.currentTimeMillis();

                LOGGER.debug("About to loop, epochMs {}, newEpochMs {}", epochMs, newEpochMs);
                while (newEpochMs <= epochMs) {
                    LockSupport.parkNanos(PARK_NANOS);
                    newEpochMs = System.currentTimeMillis();
                }
                return State.ofNewTimestamp(newEpochMs);
            }
        }
Each call will generate a new globally unique ID.
stroom-util/src/main/java/stroom/util/concurrent/UniqueIdGenerator.java