Avoid messing around with Math.random().
Actually Math.random() uses a Random object to create its output.Daniel Hirning wrote: . . . I understand that they both came out in JDK 1.0, . . .
I thought java.util.Random was thread‑safe. But it does say in the link that you may get poor performance and suggests something different for multithreaded use.Matthew Brown wrote: . . . you can let each thread, or each component, have its own generator to reduce synchronization conflicts . . .
Campbell Ritchie wrote:
I thought java.util.Random was thread‑safe. But it does say in the link that you may get poor performance and suggests something different for multithreaded use.Matthew Brown wrote: . . . you can let each thread, or each component, have its own generator to reduce synchronization conflicts . . .
Daniel Hirning wrote:That clears it up I think. Class Math while simpler to use is not thread safe
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Your definition is obviously different from mine...
Consider Paul's rocket mass heater. |