type threads=class (tthread)
lab:tlabel;
cur: integer;
max:integer;
private
procedure init ;
protected
procedure execute;override ;
public
constructor create(l:tlabel;m:integer);
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
with threads.create(label1,1000000)do
end;
{ threads }
constructor threads.create(l: tlabel;
m: integer);
begin
FreeOnTerminate:=true;
lab:=l;
max:=m;
inherited create(false);
end;
procedure threads.execute;
var
i:integer;
begin
for i:=0 to maxdo
begin
if not Terminated then
Synchronize(init);
cur:=i;
end;
end;
procedure threads.init;
begin
lab.Caption:=inttostr(cur);
end;
end.