java登录唯一_java – randomUUID是否提供唯一的ID?

Randomly generated UUIDs have 122 random bits. Out of a total of 128

bits,four bits are used for the version (‘Randomly generated UUID’),

and two bits for the variant (‘Leach-Salz’).

With random UUIDs,the

chance of two having the same value can be calculated using

probability theory (Birthday paradox). Using the approximation

p(n)\approx 1-e^{-\tfrac{n^2}{{2x}}}

these are the probabilities of an

accidental clash after calculating n UUIDs,with x=2122:

n probability

68,719,476,736 = 236 0.0000000000000004 (4 × 10−16)

2,199,023,255,552 = 241 0.0000000000004 (4 × 10−13)

70,368,744,177,664 = 246 0.0000000004 (4 × 10−10)

To put these numbers into perspective,the annual risk of someone being hit by a meteorite is estimated to be one chance in 17 billion,which 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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值