Well, problem was the way in which I was generating random numbers. Look at the following snippet.
Random randomGen = new Random(System.currentTimeMillis());
Looks very simple and straightforward. But this line was part of a function. Which was structured as
fun()
{
for 1 to 1000
doRandom()
}
...
doRandom()
{
Random randomGen = new Random(System.currentTimeMillis());
number = randomGen.nextInt();
...
}
Has anyone reading it, figured out the problem with above code and why it will work fine while debugging?
If you have. Kudos.
The problem here is seed I am using i.e. System.currentTimeMillis().
- This seed will remain same for next 1/1000th of a second
- That's lots of time for a computer
- While debugging, every break point I place will result in delay and hence will lead to generation of different seed
private Random _randomGen = new Random(System.currentTimeMillis());
...
doRandom()
{
number = _randomGen.nextInt();
...
}
3 comments:
This is a Heisen-bug
It is remarkable, this very valuable message
*Buy 100 Mg Augmentin get lipitor with out prescription Online generic Kamagra Levitra no prescription cod Lasix Cheap Find Flagyl ER buy online surgery after unsin flomax cheap Levitra by fedex cod Lasix buy online purchase Avelox cod cash delivery
Post a Comment