Is it possible to generate duplicate UUIDs in the same millisecond?
Is it possible to create two duplicate UUIDs one after the other? I'm unfamiliar with how UUIDs are generated, but I would guess that if you created two separate UUIDs from the same MAC address in the same millisecond, then they would be exactly the same. Is this true?
I guess I'm asking two questions in one. I'm very interested to know what parameters are used to generate a random UUID. I'm guessing its more than just timestamp and MAC address.
In the Python UUID package, it takes the timestamp and generates a random number random.randrange(1<<14L) for UUIDv1 , so you are taking a nanosecond timestamp plus a random number from 1 to 16384 , so... My guess is it would be possible but highly unlikely.
If you are worried about this being an issue, you always have UUIDv3 , UUIDv4 , and my choice, UUIDv5 .
上一篇: 如何在Java中生成真正的UUID?
