[阅读: 385] 2005-01-19 05:58:47
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
tyw = class
public
TmpIntA: integer;
TmpIntB: integer;
TmpIntC: integer;
end;
pyw = ^tyw;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
function ExecThread(tmpA,tmpB:integer):integer;
function GetSumAB(Tmpyw:pyw):integer;
end;
type
TMyThread = class(TThread)
private
protected
procedure Execute;override;
public
constructor Create(Tmpyw:pyw);virtual;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function TForm1.ExecThread(tmpA,tmpB:integer):integer;
var
yw : pyw;
fyw: tyw;
begin
fyw := tyw.Create;
yw := @fyw;
fyw.TmpIntA := 1;
fyw.TmpIntB := 2;
if GetSumAB(yw) = 0 then //这里GetSumAB(yw)是一个函数
showmessage(IntToStr(yw.TmpIntC));
end;
function TForm1.GetSumAB(Tmpyw:pyw):integer;
begin
//这里创建一个线程,在线程中执行fyw.TmpIntA和fyw.TmpIntB的和,然后赋给fyw.TmpIntC
end;
constructor TMyThread.Create(Tmpyw:pyw);
begin
inherited Create(True);
//这里是线程创建时初始化的语句。
end;
procedure TMyThread.Execute;
begin
//线程执行的代码
end;
end.