Ich stelle mir das so vor:
Delphi-Quellcode:
procedure TMyThread.Execute();
var
Msg: String;
c: boolean;
begin
while not Terminated do
begin
EnterCriticalSection(..);
if not Connection[SockId].Connected then break;
Msg := Connection[SockId].ReadLn;
WriteLn(Msg);
LeaveCriticalSection(..);
end;
end;
Delphi-Quellcode:
//erst die Threads beenden, damit keine Fehler auftreten
for i := 0 to High(Connection) do begin
EnterCriticalSection(..);
Connection[i].Disconnect;
LeaveCriticalSection(..);
end;
Also z.B. für den Thread (für jede Instanz!) eine TCriticalSection definieren.