[fpc-devel] Random thread-safe

Mark Morgan Lloyd markMLl.fpc-devel at telemetry.co.uk
Thu Jan 28 23:51:27 CET 2016


Jonas Maebe wrote:
> Mark Morgan Lloyd wrote:
>> Could I ask for clarification of this please. Are you saying that
>> Random() will crash if called simultaneously by multiple threads, or
>> that it will return suboptimal results?
> 
> It's undefined. The current implementation won't crash, but the results 
> will indeed be suboptimal.
> 
>> If, as an example, I have two threads doing network or comms jobs and I
>> want to introduce jitter in the retries, does that mean that I have to
>> put Random() into a critical section?
> 
> Yes.

Thanks Jonas, noted.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-devel mailing list