日期:2014-05-20 浏览次数:21236 次
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
public class UUID {
public static void main(String[] args) {
final int x = Integer.parseInt(args[0]);
final int y = Integer.parseInt(args[1]);
final String[][] uuids = new String[x][y];
final int[] ks = new int[x];
for(int j = 0; j < x; j++) {
final int k = j;
new Thread(new Runnable(){
public void run() {
for(int i = 0; i < y ; i++) {
uuids[k][i] = getUUID();
}
System.out.println(k + " Over.");
ks[k] = 1;
}
}).start();
}
while(true) {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
boolean flag = true;
for(int i = 0; i < ks.length; i++) {
if(ks[i] == 0) {
flag = false;
}
}
if(flag) {
break;
}
}
System.out.println("Process UUID");
HashSet<String> set = new HashSet<String>(uuids.length);
List<String> list = new ArrayList<String>();
for(int i = 0; i < uuids.length; i++) {
for(int j = 0; j < uuids[i].length; j++) {
if(!set.add(uuids[i][j])) {
list.add(i + "#" + j + "#" + uuids[i][j]);
System.out.print(uuids[i][j] + "| ");
} else {
System.out.print(uuids[i][j] + "| ");
}
}
System.out.println();
}
System.out.println("Process UUID ["+set.size()+"]");
System.out.println(list);
}
public static String getUUID() {
String s = java.util.UUID.randomUUID().toString();
return s.substring(0, 8) + s.substring(9, 13) + s.substring(14, 18)
+ s.substring(19, 23) + s.substring(24);
}
}
5 Over.
0 Over.
8 Over.
4 Over.
6 Over.
9 Over.
2 Over.
3 Over.
7 Over.
1 Over.
Process UUID
111a259c52fb4ea7b313fe33cd2b1a56| def2c8f802e546b49594498809349d9f| 89c3b3bb1772471d9275f763cc82a655| e1af69b5744d4bf69b19b3425c5ac355| a46218ea0f574444b3c8af738e6d05cc| d8df2b2741b24d3ca672d7f9bc78e3c1| 4223d0ca2bf944bb8d64a7867e150dd3| 023deb9163784ccebb0703a778fa03eb| 96763ee8c91c45b1a21435c1031dcbde| 033070ce7d2f4614b700a1ffaffaaa3e|
333bf61aa8634e47b2d1f7df150d979f| ec2d4226cf3c4299aad3e97f246f0142| 073aed8d9d8748668c377875bf7e9a6e| fe87c53421cc4505b75dacc3b7928fa5| 1c9a6af7699d433ea4652c3514c4cfc6| f0d74353fa8946a19803609f06d32865| 9ccda1bce1ec4de08751a764f75bc8b0| e98cac7671ab4e1fa345cb5ebbf5f2da| 324089828b4a419e9c2487f2e2ea4f24| a6ec9e64bae24ea0a710d58e522b4de2|
cf2bf25509014e52982807c5a8d9c5d4| cdb6b5324f854b9d83d9c13c132e77f1| 2e1744970d2c4c3484743b3e0a147e99| 33009f87cde14e12ad59687acf7ec9e7| e4c133edc254472dba68853a50428d79| 89c833fef714490ea3f381843ae2e551| 8c1ea95e616f477383e4d7176b759da0| f4459e074ade466683433d1dc594fc5a| 11ef5a7199f24372ad88db69d68faac8| df197fdee0d74602809e76b965ebeb7f|
c4c2a850be104db9b7d41160534938c5| f2bb56c27f884cfcb31e218de6d6e4b2| 1bd40a566ca94f0b804d7c9531174874| be9dac6ce5ed44868044d1064fc56dc8| d5c1e4c19d1d41169e4d660e90a537b6| 85ba87dc52af4b648d671da289f1bfb9| 19229b03f5974c7c93918979029d41fd| eed6b3f6a8ea4e84b14d29dc3733523c| 86b962d554094bddafe3f271fe0b63a4| 59ebdc9463fd4ba0ad8ed7c1f36632f9|
6654487027d34877af2baedefa90f59a| f0af4400bae34ee9b3aaa26f5eb5b7d1| 771d748b63ac4e2c9ac822199c984667| 3d8f4443720245d9a2b4f822ad8ae5d0| 513d79eeb16b461ca1ec549fd54ec709| 6fc2a02fc70c4f15baa0316d4901d74d| fea0ef82baf442e4bd2931e002e95dae| 200cd15ac49446e0abfec9d5526cd5b6| 48e2b7118cfe4f96b2f513b9ba9871bb| a167bb66880d4ce38779a64439255673|
9b5c9f50fdfa4414b1180a0bbed9b34f| 43156bc3897a4156a3d2e9d2a73b6677| 510d51eff3204412af4f2b2b18030aba| 0dfe8dca76464a7ab1705691df9e8370| 81da5ae024244fdaacc1b92104956f4e| dd2c42697c924b47a23099db3b1afc35| aab508823d174939b9c48030c25536d7| cea7d8f6700c424ea7ab03d923147c8a| 8b69c816c1e547769341cde9c8d78453| 6ee86e999ab04c9d947bf4f722474b0e|