一个关于多线程的简单实例(抄书)

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1
= class(TForm)
lblTime: TLabel;
btnAdd: TButton;
edt1: TEdit;
edt2: TEdit;
edt3: TEdit;
lbl1: TLabel;
lbl2: TLabel;
procedure btnAddClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
timethread
= class(TThread)
protected
procedure execute;override;
end;
var
Form1: TForm1;
TIME_THREAD:timethread;

implementation

{$R *.dfm}

{ timethread }

procedure timethread.execute;
var
go:Boolean;
timestring:
string;
begin
go:
=True;
repeat
timestring:
=FormatDateTime('H:mm:ss am/pm',now);
Form1.lblTime.Caption:
=timestring;
until go=False;
end;

procedure TForm1.btnAddClick(Sender: TObject);
begin
edt3.Text:
=IntToStr(StrToInt(edt1.Text)+strtoint(edt2.Text));
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
TIME_THREAD:
=timethread.Create(false);
end;

end.

原文地址:https://www.cnblogs.com/ljjphysics/p/2121960.html