C++ Builder 参考手册 ➙ TThread ➙ FreeOnTerminate
头文件:#include
命名空间:System::Classes
类:TThread
访问权限:public:
属性定义:
__property bool FreeOnTerminate = { read = FFreeOnTerminate, write = SetFreeOnTerminate, nodefault };
System::Classes::TThread::FreeOnTerminate 是 System::Classes::TThread 的属性,线程结束是是否自动销毁线程对象。
- 如果 FreeOnTerminate 属性置为 true,Execute 方法执行结束,线程就会被销毁,所以构造函数的参数要为 true 即创建出来的时候线程挂起,然后用 Start 方法开始执行,调用 Start 方法之后,就不要在 Execute 方法之外的任何地方调用类的成员了,除非确认这个对象还没被销毁。
例子:
请参考 TThread::OnTerminate 的例子;
请参考 TThread::Execute 的例子。
参考:
- System::Classes::TThread::Start
- System::Classes::TThread::Terminate
- System::Classes::TThread::Terminated
- System::Classes::TThread::OnTerminate
- System::Classes::TThread::FatalException
- System::Classes::TThread::Execute
- System::Classes::TThread
- System::TObject
- VCL 类继承关系
C++ Builder 参考手册 ➙ TThread ➙ FreeOnTerminate