[Lazarus] thread safe

Michael Schnell mschnell at lumino.de
Thu Jun 30 15:40:18 CEST 2011


On 06/30/2011 01:53 PM, Lukasz Sokol wrote:
>
> AFAIR, code (whatever way you write it) can either BE safe or NOT, no
> half measyres here - any one of the 'properties' vel 'aspects' not
> complied with, and you can't name your code thread-safe.
A function easily can be thread safe _only_ if a parameter of same is 
different for each thread:

var
  a array [0...10] of Integer;
Function x(i);
begin
   a[i] := a[i] + 1;
end;

A very likely case with the hidden self parameter of class instances.

-Michael




More information about the Lazarus mailing list