The UUID (universally unique Identifier) Globally unique identifier, which is a number generated on a machine that guarantees that all machines in the same time and space are unique. Based on the standard calculations developed by the Open Software Foundation (OSF), Ethernet card addresses, nanosecond time, chip ID codes, and many possible numbers are used. A combination of the following: the current date and time (the first part of the UUID is related to the time, if you generate a UUID after a few seconds, the first part is different, the rest is the same), the clock sequence, the globally unique IEEE Machine identification number (if there is a network card, from the network card, No network cards are available in other ways), the only drawback to the UUID is that the resulting string will be longer
The UUID is a 128-bit long number, usually expressed in 16 notation. The core idea of the algorithm is to combine the machine's NIC, local time, and a random number to generate the UUID. Theoretically, if a machine produces 10 million UUID per second, it is guaranteed (in a probabilistic sense) that it will not repeat for 3,240 years. In this way, everyone can create a UUID that does not clash with others. In such a case, there is no need to consider the name duplication problem when the database is established.
The UUID is a new class in 1.5, which, under Java.util, can produce a globally unique ID.
Package UUID;
Import Java.util.UUID;
public class Test {
public static void Main (string[] args) {
String uuid = Uuid.randomuuid (). toString ();
SYSTEM.OUT.PRINTLN (UUID);
}
}
Here are the results I ran three times
D0cd48ef-313a-405c-ac76-12cce5657dca
d7e1e24b-9574-4ea0-a08f-4cfa6965035f
C6b75eef-f6ca-4963-8c4f-26b72cb15eee
。
UUID in Java