Question

My guess is that class variables ("class var") are truly global in storage (that is, one instance for the entire application).

But I am wondering whether this is the case, or whether they are thread in storage (eg similar to a "threadvar") - once instance per thread.

Anyone know?

Edit: changed "scope" to "storage" as this is in fact the correct terminology, and what I am after (thanks Barry)

Was it helpful?

Solution

Yes, class variables are globally scoped. Have a look in the RTL source for details of how threadvars are implemented. Under Win32 each thread can have a block of memory allocated automatically to it on thread creation. This extra data area is what is used to contain your threadvars.

OTHER TIPS

Class variables are scoped according to their member visibility attributes, and have global storage, not thread storage.

Scope is a syntactic concept, and relates to what identifiers are visible from where. It is the storage of the variable that is of concern here.

Class variables are just like classes: global and unique for the application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top