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


           
           if (datacenterId > maxDatacenterId || datacenterId < 0)
           {
               throw new ArgumentException(string.Format(\"datacenter Id can't be greater than %d or less than 0\" maxDatacenterId));
           
           this.workerId = workerId;
           this.datacenterId = datacenterId;
       

       public long nextId()
       {
           lock (syncRoot)
           {
               long timestamp = timeGen();

               if (timestamp < lastTimestamp)
               {

推荐阅读