5,935
社区成员
发帖
与我相关
我的任务
分享
[/quote]
重写线程的构造函数和析构函数(构造函数中可以任意数量的参数)
constructor Create(aList: TListView);
Destructor Destroy; override;
在线程单元中定义一个公共LIstView对象,
MainListView:TListView;
在重写的构造函数中
//线程构函数函数----------------------------------------------------------------
constructor TDemoThread.Create(aList: TListView);
begin
MainListView:= aList;
FreeOnTerminate:=true; //标志着线程执行完毕后,自动释放资源
inherited Create(true); //线程创建时不执行,指定运行后方才执行,如果设为False,则一创建就运行
end;
//析构函数
//线程析构函数------------------------------------------------------------------
destructor TDemoThread.Destroy;
begin
MainListView := nil;
inherited;
end;

