MyThread = class(TThread)
private
procedure Execute;override;
end;
procedure MyThread.Execute;
var
i: integer;
begin
for i:=0 to 20 do
begin
//原因类似于oc,oc的标记变量需要手工定义,delphi不需要定义
if not Terminated then
begin
Form1.Edit1.Text := IntToStr(i);
Sleep(500);
end
else
Break;
end;
end;
if Assigned(tt) then
begin
// 会首先把Terminated 这个变量=false
tt.Free;
end;