The documentation says that a "BeginThread" needs to be followed by a "CloseThread". The implementation of TThread did not respect this yet.

Note: The only RTL where this could lead to problems is for BeOS with the old threading implementation as this does not use "BeginThread" at all (the newer implementation does).

rtl/objpas/classes/classes.inc, TThread.Destroy:
  * call "CloseThread" if the thread handle is valid (mimics the logic of the Windows RTL)
rtl/win/tthread.inc, TThread.SysDestroy:
  * remove the call to "CloseHandle"; this is done by "CloseThread" afterwards

git-svn-id: trunk@24313 -
This commit is contained in:
svenbarth 2013-04-23 20:13:07 +00:00
parent 6c1ea83c5a
commit bd7cc36ea6
2 changed files with 4 additions and 2 deletions
rtl
objpas/classes
win

View File

@ -191,8 +191,11 @@ end;
destructor TThread.Destroy;
begin
if not FExternalThread then
if not FExternalThread then begin
SysDestroy;
if FHandle <> TThreadID(0) then
CloseThread(FHandle);
end;
RemoveQueuedEvents(Self);
DoneSynchronizeEvent;
{ set CurrentThreadVar to Nil? }

View File

@ -32,7 +32,6 @@ begin
Start;
WaitFor;
end;
CloseHandle(FHandle);
end;
FFatalException.Free;