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
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to