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


                   throw new ApplicationException(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

推荐阅读