Java – is it really unique to use the unique ID generation of UUID?

I want to generate unique IDs, just like automatic increment in Java So I used the current nanosecond before, but I finally collided because the two data are in the same nanosecond

Note: in my project, I can even get 10000 rows of records per minute. I will dump these records into the table together with UIDs There may be a situation where I will stop my product and restart after a period of time So in this case, how does the UUID class clarify the previously generated UIDs (which I store in the DB) and the new ones (which will be dumped in the DB)?

Solution

Although UUID is not guaranteed to be unique, the probability of repetition is very low See random UUID probability of duplicates

Using UUIDs makes sense for your application, but you may want to handle extremely rare situations just in case

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>