unit PrimeThread; interface uses Classes; type TPrimeThrd = class(TThread) private FTestNumber: integer; protected function IsPrime: boolean; procedure Execute; override; public property TestNumber: integer write FTestNumber; end; implementation uses SysUtils, Dialogs; function TPrimeThrd.IsPrime: boolean; var iter: integer; begin result := true; if FTestNumber < 0 then begin result := false; exit; end; if FTestNumber <= 2 then exit; for iter := 2 to FTestNumber - 1 do begin if (FTestNumber mod iter) = 0 then begin result := false; {exit;} end; end; end; procedure TPrimeThrd.Execute; begin if IsPrime then ShowMessage(IntToStr(FTestNumber) + 'is prime.') else ShowMessage(IntToStr(FTestNumber) + 'is not prime.'); end; end.