class IdWorker {

    public synchronized long nextId() {  
        long timestamp = timeGen();  
  
        if (timestamp < lastTimestamp) {  
            LOG.error(String.format("clock is moving backwards.  Rejecting requests until %d.", 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 - twepoch) << timestampLeftShift) | (datacenterId << datacenterIdShift) | (workerId << workerIdShift) | sequence;  
    }

    public  IdWorker(long workerId, long datacenterId);

}