### Question:
SnowflakeIdWorker { public synchronized long nextId() { long timestamp = timeGen(); if (timestamp < lastTimestamp) { throw new RuntimeException( String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); } if (lastTimestamp == timestamp) { sequence = (sequence + 1) & sequenceMask; if (sequence == 0) { timestamp = tilNextMillis(lastTimestamp); } } else { sequence = 0L; } lastTimestamp = timestamp; return (timestamp << timestampLeftShift) | (dataCenterId << dataCenterIdShift) | (workerId << workerIdShift) | sequence; } SnowflakeIdWorker(long workerId, long dataCenterId); synchronized long nextId();  }### Answer:
@Test public void testNextId() { Set<Long> idSet = new HashSet<>(); int i = 0; while (i++ < 100) { long result = snowflakeIdWorker.nextId(); idSet.add(result); } Assert.assertEquals(idSet.size(), 100); }