var
PrimeGrid:
array of Boolean;
implementation
{ TPrimeThread }
procedure TPrimeThread.CalcPrimes(EndNum: Int64);
var
NotAPrime, CurrPrimeCandidate: Int64;
begin
CurrPrimeCandidate := 2;
SetLength(PrimeGrid,EndNum+1);
FillChar(PrimeGrid, SizeOf(PrimeGrid), #1);
PrimeGrid[1] := False;
while (CurrPrimeCandidate < EndNum)
do
begin
// Hab das hiermit mal debugt und es tritt genau bei dem Wert auf
if CurrPrimeCandidate = 7126783
then
begin
asm
int 3
end;
end;
if PrimeGrid[CurrPrimeCandidate]
then // hier Zugriffsverletzung wenn CurrPrimeCandidate = 7126783
begin
NotAPrime := CurrPrimeCandidate * 2;
while NotAPrime <= EndNum
do
begin
PrimeGrid[NotAPrime] := False;
Inc(NotAPrime, CurrPrimeCandidate);
end;
end;
CurrPrimeCandidate := CurrPrimeCandidate + 1;
end;
end;
procedure TPrimeThread.Execute;
begin
CalcPrimes(10000000);
end;