用TList,或TStrings来管理,
加载线程的OnTermiated事件
procedure TForm1.AddThread(Name: string = '');
var
Thread: TMyThread;
ThreadName: string;
begin
if Name = '' then
ThreadName := IntToStr(FList.Count + 1);
Thread := TMyThread.Create(...);
Thread.OnTermated := OnThreadTermiated;
FList.AddObject(ThreadName, Thread);
end;
//Thread 's OnTermiated Event
procedure TForm1.OnThreadTermiated(Sender: TObject);
var
Index: Integer;
begin
Index := FList.IndexOfObject(Sender);
if Index <> -1 then
begin
//TODO: Add you code
ShowMessage('第'+Flist+'死了');
FList.Delete(Index);
end;
end;