Threads and Static Data

Regan Heath regan at netmail.co.nz
Tue Dec 11 01:51:12 PST 2007


Jérôme M. Berger wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Regan Heath wrote:
>> Sean Kelly wrote:
>>> Craig Black wrote:
>>>> Suite!  I think I've seen the term "thread local", but it never
>>>> occured to me what it meant.  Goes to show you how green I am when it
>>>> comes to threading.  I'll check it out.  Thanks.
>>> For what it's worth, some C/C++ compilers have "thread local" as a
>>> storage class.  I've proposed adding this to D before, but there
>>> seemed to be no interest at the time.
>> If I want thread local storage I just add the variables as static
>> members of the class I've derived from Thread.
>>
>> Does thread local storage give us some advantage over that?
>>
> 	But if you want to launch several instances of this thread at the
> same time, your variables won't be local, will they?

What do you mean by "local"?

If you want a copy of the variables for each thread, make them 
non-static members of the thread.

Regan



More information about the Digitalmars-d mailing list