且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Java中生成全局唯一标识符

更新时间:2023-02-07 13:57:44

非常确定UUID足够好。有340,282,366,920,938,463,463,374,607,431,770,000,000 UUID可供使用。

Pretty sure UUIDs are "good enough". There are 340,282,366,920,938,463,463,374,607,431,770,000,000 UUIDs available.

http: //www.wilybeagle.com/guid_store/guid_explain.htm

为了对这些数字进行透视,每年被陨石击中的风险是估计是170亿的一次机会,这意味着概率约为0.00000000006(6×10-11),相当于一年内创造几十万亿UUID并且有一个重复的几率。换句话说,只有在未来100年内每秒生成10亿UUID后,创建一个重复的概率约为50%。如果地球上每个人拥有6亿UUID,则一次重复的概率约为50%

"To put these numbers into perspective, one's annual risk of being hit by a meteorite is estimated to be one chance in 17 billion, that means the probability is about 0.00000000006 (6 × 10−11), equivalent to the odds of creating a few tens of trillions of UUIDs in a year and having one duplicate. In other words, only after generating 1 billion UUIDs every second for the next 100 years, the probability of creating just one duplicate would be about 50%. The probability of one duplicate would be about 50% if every person on earth owns 600 million UUIDs"

http://en.wikipedia.org/wiki/Universally_Unique_Identifier