标签:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; Edit2: TEdit; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; type //线程类 TMyThread = class(TThread) private PNum1, PNum2: Integer; MyEdit: TEdit; protected procedure Execute; override; public constructor Ctreate(Num1, Num2: Integer; edit: TEdit); end; var Form1: TForm1; implementation {$R *.dfm} constructor TMyThread.Ctreate(Num1, Num2: Integer; edit: TEdit); begin PNum1 := Num1; PNum2 := Num2; MyEdit := edit; FreeOnTerminate := True; inherited Create(False); end; procedure TMyThread.Execute; var i, k: Integer; begin //线程执行的地方,你可以改成自己的计算过程或者函数 k := 0; for i := 0 to 10000000 do k := k + PNum1 * i + PNum2 * i; MyEdit.Text := IntToStr(k); end; procedure TForm1.Button1Click(Sender: TObject); var MyCalc: Tcalc; begin MyCalc := Tcalc.Ctreate(1, 1, edit1); MyCalc := Tcalc.Ctreate(1, 1, edit2); end; end.
标签:
原文地址:http://www.cnblogs.com/imjeek/p/5642093.html