commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Boris Unckel" <b.unc...@gmx.net>
Subject Re: [POLL] System.currentTimeMillis()
Date Thu, 15 Dec 2005 17:54:58 GMT
Hi Joerg,

this is an absolutely "normal" behaviour. It does not depend
on the operating system, but more on system speed.
Your CPU has enough power to calculate n-thousand additions
in one milli second.
It is not predictable, since it depends on the machine in use.

I have found this in an other context:
Random  r1 = new Random(); //depends on System.currentMillis()

If you have the need to randomize more than one number (and cannot
rely on the same random object) you need one random for the seed,
and one random for the number generating:

private static final Random RANDOM_FOR_SEED = new Random();
//....
public int generateRandomInt(){
 Random localRandom = new Random(RANDOM_FOR_SEED.nextLong());
 return localRandom.nextInt(100);
}

Regards
Boris

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message