[fpc-pascal] TThread.Queue vs TThread.Synchronize
Sven Barth
pascaldragon at googlemail.com
Mon Feb 23 20:55:20 CET 2015
On 23.02.2015 20:49, Philippe Lévi wrote:
> sorry ... I still not understand the "idea".
>
>
> if code in thread access a local variable (in stack) of the function
> where thread is issued ... it may access "something" which does not
> exist any more. correct?
It's not about the thread, but about the scope. As long as you pass a
nested procedure around and that is only stored/used as long as the
procedure in which the nested procedure is declared is in scope as well
everything is fine. But once the surrounding procedure exits the
procedure variable is no basically no longer valid, because the stack
frame of the outer procedure no longer exists.
Only anonymous functions/closures will change that.
Regards,
Sven
More information about the fpc-pascal
mailing list