[fpc-pascal] Does TThread.Execute terminate thread on exit?

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Sun Nov 1 18:25:55 CET 2015


Tobias Giesen wrote:
> Yes it will terminate and free (if FreeOnTerminate is true).

Remember that if it frees itself due to falling out of the Execute() 
procedure, a variable containing the TThread descendant won't be set nil.

On the other hand, if it doesn't free itself and relies on the main 
thread checking an "executing" flag, there's a race condition between 
this being reset and its being safe for the main thread to call 
FreeAndNil().

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-pascal mailing list