unit PrimeThread;
 
interface
 
uses
 Classes;
 
type
 TPrimeThrd = class(TThread)
 private
 FTestNumber: integer;
 FResultString: string;
 protected
 function IsPrime: boolean;
 procedure UpdateResults;
 procedure Execute; override;
 public
 property TestNumber: integer write FTestNumber;
 end;
 
implementation
 
uses SysUtils, Dialogs, PrimeForm;
 
procedure TPrimeThrd.UpdateResults;
begin
 PrimeFrm.ResultsMemo.Lines.Add(FResultString);
end;
 
function TPrimeThrd.IsPrime: boolean; {omitido para ser breves}
 
 procedure TPrimeThrd.Execute;
 begin
 if IsPrime then
 FResultString := IntToStr(FTestNumber) + ' es primo.'
 else
 FResultString := IntToStr(FTestNumber) + ' no es primo.';
 Synchronize(UpdateResults);
 end;
 
end.