G
gxch
Unregistered / Unconfirmed
GUEST, unregistred user!
请看下面的一段小程序,我执行时startid,endid两个数都是零,我对线程内和线程间的参数传递不是很明白,请大家讲讲好吗?
unit Unit2;
interface
uses
Classes,SysUtils;
type
thadd = class(TThread)
private
startid,endid:integer;
protected
procedure Execute;
override;
public
constructor create(Suspended:boolean;startid:integer;
endid:integer);
end;
implementation
procedure thadd.Execute;
var
i:integer;
begin
for i:=1 to endiddo
begin
startid:=i+1;
end;
end;
constructor thadd.create(Suspended:boolean;startid:integer;
endid:integer);
begin
inherited Create(suspended);
FreeOnTerminate:=true;
startid:=startid;
endid:=endid;
end;
end.
unit Unit2;
interface
uses
Classes,SysUtils;
type
thadd = class(TThread)
private
startid,endid:integer;
protected
procedure Execute;
override;
public
constructor create(Suspended:boolean;startid:integer;
endid:integer);
end;
implementation
procedure thadd.Execute;
var
i:integer;
begin
for i:=1 to endiddo
begin
startid:=i+1;
end;
end;
constructor thadd.create(Suspended:boolean;startid:integer;
endid:integer);
begin
inherited Create(suspended);
FreeOnTerminate:=true;
startid:=startid;
endid:=endid;
end;
end.