Is Java’s random UUID unique ?

<p>Java&rsquo;s&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/UUID.html" rel="noopener ugc nofollow" target="_blank">java.util.UUID</a>&nbsp;represents an immutable universally unique identifier (UUID). In particular the static&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/UUID.html#randomUUID--" rel="noopener ugc nofollow" target="_blank">randomUUID()</a>&nbsp;method of this class generates UUID which can be used as a unique identifier in distributed systems. But, is this UUID unique ? What are the chances that multiple calls to randomUUID() method will generate the same UUID ? What are the chances that such calls in distributed systems will result in duplicate identifiers ? Lets find out !</p> <h2>UUID</h2> <p><a href="https://www.ietf.org/rfc/rfc4122.txt" rel="noopener ugc nofollow" target="_blank">RFC4122</a>&nbsp;details out the complete UUID specification. A Universally Unique Identifier (UUID) represents a 128-bit value, i.e. 16 octets. Two most important fields determine the structure of UUID:</p> <p><a href="https://medium.com/@saksenaprashant06/is-javas-random-uuid-unique-051af669f6e7"><strong>Website</strong></a></p>
Tags: Javas Random