code: private synchronized long nextId(boolean isPadding, long busId) {
  
          long timestamp = timeGen();
          long paddingnum = regionId;
  
          if (isPadding) {
              paddingnum = busId;
          }
  
          if (timestamp < lastTimestamp) {
              try {
                  throw new Exception("Clock moved backwards.  Refusing to generate id for " + (lastTimestamp - timestamp) + " milliseconds");
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
  
          //如果上次生成时间和当前时间相同,在同一毫秒内
          if (lastTimestamp == timestamp) {
              //sequence自增，因为sequence只有10bit，所以和sequenceMask相与一下，去掉高位
              sequence = (sequence + 1) & sequenceMask;
              //判断是否溢出,也就是每毫秒内超过1024，当为1024时，与sequenceMask相与，sequence就等于0
              if (sequence == 0) {
                  //自旋等待到下一毫秒
                  timestamp = tailNextMillis(lastTimestamp);
              }
          } else {
              // 如果和上次生成时间不同,重置sequence，就是下一毫秒开始，sequence计数重新从0开始累加,
              // 为了保证尾数随机性更大一些,最后一位设置一个随机数
              sequence = new SecureRandom().nextInt(10);
          }
  
          lastTimestamp = timestamp;
  
          return ((timestamp - twepoch) << timestampLeftShift) | (paddingnum << regionIdShift) | (workerId << workerIdShift) | sequence;
      }
docs: 实际产生代码的
  @param isPadding
  @param busId
  @return