Am Sa., 22. Dez. 2018, 17:38 hat Bart <
geschrieben:
On Sat, Dec 22, 2018 at 1:03 PM Franz Müller <
wrote: But maybe there is an easy way to save the state of the random
number generator routine before sorting and to restore it when the sort is done?
Save RandSeed and restore it after you're done with your calls to Random
Please note that this is not threadsafe as another thread running the same or even different code could poke around in the RNG's state as well.
Regards,
Sven
Well, the random number generator itself is not threadsafe anyway. So if you use threads and need deterministic pseudo-random numbers, you should encapsulate the RNG into a class that takes care of this.
On the other side, every component and every piece of code that uses random number will interfere with code that needs reproducible pseudo-random numbers. So if you need that, it certainly is a good idea to keep control of randseed in your own code, even if you don't use threads. After thinking it over, I feel TStringlist should not take care of this problem, rather the program that needs reproducible numbers should. What would you suggest?
