Am 06.05.2016 11:34 schrieb "LacaK" <la...@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
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to