FaithlessThinker
New Member
Inspired by nophun... And the pun in the title was unintended
So this is a Java application (console-based) that I created which utilizes concurrently running^ threads to create a 10-digit random number (without repetition of digits).
I know there are various methods to easily get random numbers in Java such as Math.random() but as nophun says, "Why not?"
Here goes the code:
Example outputs (each output occured on a fresh new run):
Now my question to you all is:
^ They do not actually run concurrently but are scheduled by the operating system or the Java VM (I'm not sure which does the scheduling), with the exception that multi-core systems can run some of the threads concurrently.
* Pseudo-random means they look random to the human eye but is actually a predictable result. That's because if the random number generator is fed with the same seed over and over again, it will generate the same number over and over again.
So this is a Java application (console-based) that I created which utilizes concurrently running^ threads to create a 10-digit random number (without repetition of digits).
I know there are various methods to easily get random numbers in Java such as Math.random() but as nophun says, "Why not?"
Here goes the code:
Example outputs (each output occured on a fresh new run):
Now my question to you all is:
- Standard methods such as Math.random produces a pseudo-random* number.
- My method above utilizes threads to create a random number.
- Is this pseudo-random or truly random?
- Discuss.
^ They do not actually run concurrently but are scheduled by the operating system or the Java VM (I'm not sure which does the scheduling), with the exception that multi-core systems can run some of the threads concurrently.
* Pseudo-random means they look random to the human eye but is actually a predictable result. That's because if the random number generator is fed with the same seed over and over again, it will generate the same number over and over again.