java for loop executes too fast gives System.currentTimeMillis() duplicate
问题 Java: I have a problem using System.currentTimeMillis() function i am using System.currentTimeMillis() to generate unique values in foor loop problem is loop executes too fast and System.currentTimeMillis() gives me duplicate values. How can i generate for sure unique values. for(int a=0;a<=10;a++){ System.out.println(System.currentTimeMillis()) } I also tried following but it is also not generaet to generate unique number System.currentTimeMillis()+Math.random() 回答1: why don't you use System