C++ Builder 參考手冊 ? TThread ? FreeOnTerminate
頭文件:#include <System.Classes.hpp>
命名空間:System::Classes
類:TThread
訪問權(quán)限:public:
屬性定義:
__property bool FreeOnTerminate = { read = FFreeOnTerminate, write = SetFreeOnTerminate, nodefault };
System::Classes::TThread::FreeOnTerminate 是 System::Classes::TThread 的屬性幢哨,線程結(jié)束是是否自動銷毀線程對象。
- 如果 FreeOnTerminate 屬性置為 true拧揽,Execute 方法執(zhí)行結(jié)束芹枷,線程就會被銷毀廊驼,所以構(gòu)造函數(shù)的參數(shù)要為 true 即創(chuàng)建出來的時候線程掛起嫌拣,然后用 Start 方法開始執(zhí)行恢口,調(diào)用 Start 方法之后聂渊,就不要在 Execute 方法之外的任何地方調(diào)用類的成員了差购,除非確認(rèn)這個對象還沒被銷毀。
例子:
?? 請參考 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 類繼承關(guān)系
C++ Builder 參考手冊 ? TThread ? FreeOnTerminate