Could this cause multiple identical GUIDs?

前端 未结 4 1005
耶瑟儿~
耶瑟儿~ 2021-01-17 19:32

As GUID generation is time-dependent, if System.Guid.NewGuid() is called multiple times at the exact same instant on different threads, could it return identical GUIDs?

4条回答
  •  暖寄归人
    2021-01-17 20:28

    On Windows, GUIDs (UUIDs) are created from a cryptographic random number generator with UuidCreate. They are version 4 UUIDs in terms of RFC 4122. No timestamps or ethernet cards are involved, unless you're using old school version 1 GUIDs created with UuidCreateSequential.

    See also How Random is System.Guid.NewGuid()? (Take two)

提交回复
热议问题