unit MyThread;

interface

uses
  Classes, Sysutils;

type
  TCountObj = class(TThread)
  private
    { Private declarations }
    index:Integer;
    procedure UpdateLabel;
  protected
    procedure Execute; override;
  end;

implementation

uses Main;

{ TCountObj }

procedure TCountObj.Execute;
begin
 index:=1;
 while index>0 do
  begin
   Synchronize(UpdateLabel);
   Inc(index);
   if index>100000 then
    index:=0;
   if terminated then exit;
  end;
end;

procedure TCountObj.UpdateLabel;
begin
 Form1.Label1.Caption:=IntToStr(Index);
end;

end.



