[fpc-devel] fpc-devel Digest, Vol 176, Issue 32
    Franz Müller 
    office at focusdata.at
       
    Sun Dec 23 02:22:44 CET 2018
    
    
  
Am Sa., 22. Dez. 2018, 17:38 hat Bart <bartjunk64 at gmail.com 
<mailto:bartjunk64 at gmail.com>> geschrieben:
    On Sat, Dec 22, 2018 at 1:03 PM Franz Müller <bupa at gmx.at
    <mailto:bupa at gmx.at>> 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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20181223/7c5cdc27/attachment.html>
    
    
More information about the fpc-devel
mailing list