function Read(L: TList; Index: integer): integer;
begin
if (Index > 0) and (L.Count > Index) then
begin
with L.Items[Index] do
begin
Lock;
Result := Value;
Unlock;
end;
end
else
raise ENotFound;
end;
procedure Write(L: TList; Index: integer; NewVal: integer);
begin
if (Index > 0) and (L.Count > Index) then
begin
with L.Items[Index] do
begin
Lock;
Value := NewVal;
Unlock;
end;
end
else
raise ENotFound;
end;
function Compare(L: TList; Ind1, Ind2: integer): integer;
begin
if (Ind1 > 0) and (Ind2 > 0) and (L.Count > Ind1) and (L.Count > Ind2) then
begin
L.Items[Ind1].Lock;
L.Items[Ind2}.Lock;
Result := L.Items[Ind2].Value - L.Items[Ind1].Value;
L.Items[Ind2].Unlock;
L.Items[Ind1].Unlock;
end
else
raise ENotFound;
end;