面试题:在分布式系统,你能想出来几种生成唯一ID的方案?(14)


               {
                   sequence = 0L;
               

               lastTimestamp = timestamp;

               return ((timestamp - twepoch) << (int)timestampLeftShift) | (datacenterId << (int)datacenterIdShift) | (workerId << (int)workerIdShift) | sequence;
           
       

       protected long tilNextMillis(long lastTimestamp)
       {
           long timestamp = timeGen();
           while (timestamp <= lastTimestamp)
           {
               timestamp = timeGen();
           

推荐阅读