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

Sven Barth pascaldragon at googlemail.com
Tue Apr 23 21:40:17 CEST 2013


On 23.04.2013 16:28, Anthony Walter wrote:
> That is, it is okay to call BeginThread and never call CloseThread?
> Because that is how TThread currently works, and is in contradiction to
> the documentation.

And no one bothers to read my answer :(

Again: The only RTL that currently(!) does something inside CloseThread 
is the Windows RTL: it closes the thread handle (which was returned by 
BeginThread and is passed as an argument to CloseThread) using CloseHandle.

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...

Regards,
Sven



More information about the fpc-pascal mailing list