GUID 100%是唯一的吗?
它会在多个线程中保持唯一吗?
GUID 100%是唯一的吗?
它会在多个线程中保持唯一吗?
当前回答
简单的答案是肯定的。
Raymond Chen写了一篇关于guid和为什么guid的子字符串不能保证唯一的文章。这篇文章深入探讨了guid的生成方式以及它们用来确保唯一性的数据,这应该会花一些篇幅来解释它们为什么会这样:-)
其他回答
而每个生成的GUID不是 保证是唯一的,总数 唯一键数(2128或 3.4×1038)是如此之大,相同的数字的概率是 生成两次是非常小的。为 例如,考虑可观察对象 宇宙,其中包含约5×1022 星星;每颗恒星都有可能 6.8×1015通用唯一的guid。
从维基百科。
这是一些关于如何创建GUID(用于。net)以及如何在正确的情况下获得相同的GUID的好文章。
https://ericlippert.com/2012/04/24/guid-guide-part-one/
https://ericlippert.com/2012/04/30/guid-guide-part-two/
https://ericlippert.com/2012/05/07/guid-guide-part-three/
从http://www.guidgenerator.com/online-guid-generator.aspx
What is a GUID? GUID (or UUID) is an acronym for 'Globally Unique Identifier' (or 'Universally Unique Identifier'). It is a 128-bit integer number used to identify resources. The term GUID is generally used by developers working with Microsoft technologies, while UUID is used everywhere else. How unique is a GUID? 128-bits is big enough and the generation algorithm is unique enough that if 1,000,000,000 GUIDs per second were generated for 1 year the probability of a duplicate would be only 50%. Or if every human on Earth generated 600,000,000 GUIDs there would only be a 50% probability of a duplicate.
MSDN:
新Guid的值全为零或等于任何其他Guid的概率非常低。
I think that when people bury their thoughts and fears in statistics, they tend to forget the obvious. If a system is truly random, then the result you are least likely to expect (all ones, say) is equally as likely as any other unexpected value (all zeros, say). Neither fact prevents these occurring in succession, nor within the first pair of samples (even though that would be statistically "truly shocking"). And that's the problem with measuring chance: it ignores criticality (and rotten luck) entirely.
如果真的发生了,结果是什么?你的软件停止工作了吗?有人受伤了吗?有人死了吗?世界会爆炸吗?
临界性越极端,“概率”这个词就越难听。最后,链接guid(或XORing它们,或其他什么)是当你(主观地)认为你的特定临界性(和你的“幸运”感觉)是不可接受的时候所做的事情。如果它能毁灭世界,那么请代表我们所有没有参与大型强子对撞机核试验的人,不要使用guid或任何其他不确定的东西!
GUID 100%是唯一的吗?
不能保证,因为有几种方法可以生成一个。然而,您可以尝试计算创建两个完全相同的GUID的几率,您就会明白:一个GUID有128位,因此,有2128个不同的GUID——比已知宇宙中的恒星要多得多。阅读维基百科的文章了解更多细节。