Faisal khan Faisal khan - 3 years ago 133
Java Question

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++){

I also tried following but it is also not generaet to generate unique number


Liv Liv
Answer Source

why don't you use System.nanoTime() instead?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download