Search code examples
language-agnosticguid

Is a GUID unique 100% of the time?


Is a GUID unique 100% of the time?

Will it stay unique over multiple threads?


Solution

  • While each generated GUID is not guaranteed to be unique, the total number of unique keys (2128 or 3.4×1038) is so large that the probability of the same number being generated twice is very small. For example, consider the observable universe, which contains about 5×1022 stars; every star could then have 6.8×1015 universally unique GUIDs.

    From Wikipedia.


    These are some good articles on how a GUID is made (for .NET) and how you could get the same guid in the right situation.

    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/

    ​​