线程单元代码:
type
  sortthread = class(TThread)
  private
    fmemo:Tmemo;
    procedure add();
  protected
    procedure Execute; override;
  end;implementation
uses unit1;
procedure sortthread.add;
var
i:integer;
begin
  for i:=0 to 40000 do
  begin
  form1.memo1.Lines.Clear;
  form1.Memo1.lines.add(inttostr(i));
  end;
end;procedure sortthread.Execute;
begin
  freeonterminate:=true;
  while not terminated do
  begin
    synchronize(add);
  end;
end;主程序调用单元:
procedure TForm1.Button1Click(Sender: TObject);
var
newthread:sortthread;
begin
   newthread:=sortthread.create(false);
end;