[fpc-pascal] TThread and WaitFor
Sven Barth
pascaldragon at googlemail.com
Fri May 6 13:30:49 CEST 2016
Am 06.05.2016 11:34 schrieb "LacaK" <lacak at zoznam.sk>:
>
> Hi *,
> is this safe:
>
> FThread.Terminate; // what if here is switched FThread to execution and
will immediately end his Execute procedure
> FThread.WaitFor; // what happens if FThread is freed before WaitFor is
executed
>
> ?
>
> assuming, that FThread has FreeOnTerminate := True;
> (looking into source code it can IMO happen, that ThreadProc is ended and
data allocated to FThread instance are freed thanks to FreeOnTerminate)
>
> Is there any technique, when I need wait for thread to end execution and
still have FreeOnTerminate = True ?
Either don't use FreeOnTerminate in that case or use an event that is owned
outside of the thread and that is triggered before exiting the thread's
Execute method.
Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160506/e7bca37c/attachment.html>
More information about the fpc-pascal
mailing list