[fpc-pascal] What's the deal with CloseThread?

Sven Barth pascaldragon at googlemail.com
Wed Apr 24 09:57:41 CEST 2013

Am 24.04.2013 09:35, schrieb Marco van de Voort:
>> The Windows TThread.SysDestroy also calls CloseHandle on the handle
>> returned by BeginThread, so the semantic behavior of
>> Begin-/End-/CloseThread and TThread is the same.
>> Nevertheless in my opinion TThread needs to be adjusted so that it calls
>> CloseThread for all RTLs and the direct CloseHandle call needs to be
>> removed. And this is exactly what I will do now...
> If it makes you happy, but IMHO it is pointless.
No, it's not pointless. If we should ever have the need to add code to 
the CloseThread functions of other platforms then we don't need to 
adjust the platform specific TThread implementations. TThread uses 
BeginThread (and also EndThread) and thus by definition it should also 
use CloseThread (the only exception is the old BeOS threading 
implementation, but this is only kept around for reference).

TThread is "just" an object oriented wrapper around the procedural 
threading API, so it must adhere to its rules as well.


More information about the fpc-pascal mailing list