[fpc-devel] OO rewrite - technical questions
Michael Schnell
mschnell at lumino.de
Mon Jul 26 10:14:36 CEST 2010
On 07/24/2010 04:55 AM, Hans-Peter Diettrich wrote:
>> Moreover the point with threadvars is that threads that use the same
>> code see different values in the same threadvar. These threads of
>> course can't use different registers to access them as the run the
>> same code.
>
> Consider a threadvar as a field of a related thread object (instance).
>
It is very clear what a threadvar is: the same variable automatically is
instantiated dedicated for each thread while a normal (static or
global) variable is instantiated once for all threads. Multiple threads
that each use different code don't need threadvars as they can be
programmed to use individual static/global variables. Inly if the same
code is used for multiple threads, threadvars are necessary to allow
these threads to identify themselves (e.g a threadvar can store an ID
number for the thread so that it can know who it is without doing an OS
API call.
-Michael
More information about the fpc-devel
mailing list