Mlody87 Mlody87 - 1 month ago 19
Pascal Question

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! :)

Answer

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.