Search code examples
pascallazarus

Is TFPGMap thread safe?


I have a question about TFPGMap from fgl unit in pascal. Is this thread safe? Or I have to use Critical Section?

var map:TFPGMap;
begin
map:=TFPGMap.Create();
(...)
CS.Enter;
map.Find('Key');
CS.Leave;

Thank for answers! :)


Solution

  • Is TFPGMap thread safe?

    No it is not.

    Such classes never are threadsafe because we're they made that way then all consumers would pay the price even those that don't want to pay the price. You will need to implement your own synchronisation.