Theoretically, I don't think this method will return repeated UUIDs, even from different devices.
Let's check the documentation of android: http://developer.android.com/reference/java/util/UUID.html. It says "Generates a variant 2, version 4 (randomly generated number) UUID as per RFC 4122."
Even in JDK documentation http://docs.oracle.com/javase/6/docs/api/java/util/UUID.html , it says they are implementing RFC 4122.
And in RFC 4122, http://www.ietf.org/rfc/rfc4122.txt, it says "A UUID is 128 bits long, and can guarantee uniqueness across space and time."
Wikipedia also calculates the probability of duplicates of RandomUUID: http://en.wikipedia.org/wiki/Universally_unique_identifier#Random_UUID_probability_of_duplicates
There is a guy here (http://www.coderanch.com/t/385404/java/java/UUID-Uniqueness-JVMs) states that "We (i.e. my team at work) have been using the Java Util UUID class for UUIDs across JVMs."
However, I still can see a lot of worries that the Java randomUUID will not be unique.
First of all, let us check the wikipedia:http://en.wikipedia.org/wiki/Universally_unique_identifier. It says java is not using MAC address for generating UUID "due to lack of means to access MAC addresses using pure Java before version 6". It also gives opensource UUID generation tools as http://johannburkard.de/software/uuid/ and https://github.com/cowtowncoder/java-uuid-generator. Not sure not using MAC address will make them not unique.
Some people here (http://www.coderanch.com/t/385404/java/java/UUID-Uniqueness-JVMs) also say they are using a central control to generate UUID.
This link(http://stackoverflow.com/questions/2513573/how-good-is-javas-uuid-randomuuid ) says "implementation to contain subtle bugs that ruin all this (see OpenSSH key generation bug)".
This link(http://stackoverflow.com/questions/6505837/is-oracles-sys-guid-uuid-rfc-4122-compliant) says "SYS_GUID is Oracle's equivalent of UUID. It is globally unique. However, it is not compliant to RFC 4122".
Anyway, I do not find any evidence that says UUID.randomUUID() will repeat, even from different machines. As it says here (http://stackoverflow.com/questions/2513573/how-good-is-javas-uuid-randomuuid), "I don't think there's any concrete reason to worry about Java UUIDs's randomness."
However, if we are building very critical distributed applications with a lot of data, maybe, we can consider using MAC address algorithm, or using central UUID generator.
Let's check the documentation of android: http://developer.android.com/reference/java/util/UUID.html. It says "Generates a variant 2, version 4 (randomly generated number) UUID as per RFC 4122."
Even in JDK documentation http://docs.oracle.com/javase/6/docs/api/java/util/UUID.html , it says they are implementing RFC 4122.
And in RFC 4122, http://www.ietf.org/rfc/rfc4122.txt, it says "A UUID is 128 bits long, and can guarantee uniqueness across space and time."
Wikipedia also calculates the probability of duplicates of RandomUUID: http://en.wikipedia.org/wiki/Universally_unique_identifier#Random_UUID_probability_of_duplicates
There is a guy here (http://www.coderanch.com/t/385404/java/java/UUID-Uniqueness-JVMs) states that "We (i.e. my team at work) have been using the Java Util UUID class for UUIDs across JVMs."
However, I still can see a lot of worries that the Java randomUUID will not be unique.
First of all, let us check the wikipedia:http://en.wikipedia.org/wiki/Universally_unique_identifier. It says java is not using MAC address for generating UUID "due to lack of means to access MAC addresses using pure Java before version 6". It also gives opensource UUID generation tools as http://johannburkard.de/software/uuid/ and https://github.com/cowtowncoder/java-uuid-generator. Not sure not using MAC address will make them not unique.
Some people here (http://www.coderanch.com/t/385404/java/java/UUID-Uniqueness-JVMs) also say they are using a central control to generate UUID.
This link(http://stackoverflow.com/questions/2513573/how-good-is-javas-uuid-randomuuid ) says "implementation to contain subtle bugs that ruin all this (see OpenSSH key generation bug)".
This link(http://stackoverflow.com/questions/6505837/is-oracles-sys-guid-uuid-rfc-4122-compliant) says "SYS_GUID is Oracle's equivalent of UUID. It is globally unique. However, it is not compliant to RFC 4122".
Anyway, I do not find any evidence that says UUID.randomUUID() will repeat, even from different machines. As it says here (http://stackoverflow.com/questions/2513573/how-good-is-javas-uuid-randomuuid), "I don't think there's any concrete reason to worry about Java UUIDs's randomness."
However, if we are building very critical distributed applications with a lot of data, maybe, we can consider using MAC address algorithm, or using central UUID generator.
相关推荐
利用UUID生成完全不... UUID uuid = UUID.randomUUID(); tv.setText(uuid.toString()); } @Override public void onClick(View v) { UUID uuid = UUID.randomUUID(); tv.setText(uuid.toString()); } }
官方文档 安卓Q中Google彻底禁止第三发app获取IMEI,获取...var uniqueID = UUID.randomUUID().toString() 2.Java写法 String uniqueID = UUID.randomUUID().toString(); 2. 使用硬件信息拼接生成一个ID public stati
d2 = java.util.UUID.randomUUID(); bjson.put("b1", d2.toString()); d2 = java.util.UUID.randomUUID(); bjson.put("b2", d2.toString()); d2 = java.util.UUID.randomUUID(); bjson.put("b3", d2.toString...
Math.uuid.js js 生成 uuid
d2 = java.util.UUID.randomUUID(); bjson.put("b1", d2.toString()); d2 = java.util.UUID.randomUUID(); bjson.put("b2", d2.toString()); d2 = java.util.UUID.randomUUID(); bjson.put("b3", d2.toString...
JAVA UUID 生成.txt
OLED ROSC_ UUID.zip SYD8801
UUID.js, 用于JavaScript的符合RFC的UUID生成器 电子邮件名称UUID.js - 适用于JavaScript的兼容UUID生成器概要<!-- HTML5 -->[removed][removed]&
public class Dept { /** * 生成随机字符串 uuid */ public static String getUUID() { return UUID.randomUUID().toString(); } /** * 生成随机字符串 uuid 将"-"替换为"" */ public stat
UUID.js-JavaScript的RFC兼容UUID生成器 概要 <!-- HTML5 --> < script src =" src/uuid.js " > </ script > < script > var uuid = UUID . generate ( ) ; </ script > // Node.js...
UUID: 生成UUIDs的库,一个PHP 5.4 库生成RFC 4122版本1,3,4,5全局唯一标识符(UUID)。
在eclipse下安装theano库和cuda 运行测试文件出现无法打开文件错误,解决办法将对应的.lib文件下载放到对应的Lib文件下
<groupId>com.fasterxml.uuid</groupId> <artifactId>java-uuid-generator <packaging>bundle <name>Java UUID Generator <version>3.1.5</version>
return "".join(str(uuid.uuid4()).split("-")).upper() 补充拓展:随机产生32位随机数 1.通过uuid UUID.randomUUID().toString()这个方法可以得到32位数字和四个“-”穿插在其中 再调用 .replace(“-“,””)得到...
Uuid结构类似于System.Guid ,但具有大端字符串表示形式 怎么开 git clone git@github.com:vanbukin/Uuids.git cd ./Uuids/Uuids.CoreLib && dotnet publish -c Debug && dotnet publish -c Release (不支持....
get-uuid.tar.gz
jsp页面产生UUID.
采用纯C的方式生成全球唯一ID,guid,采用linux下的代码移植过来的,软件采用vc6编译
syncid_uuid.txt
获得设备号,给软件加密,有一定学习价值。