How does D lang handle multithreaded applications and static members of classes?

Daniel Daniel
Wed Apr 2 08:38:32 UTC 2025


On Wednesday, 2 April 2025 at 08:33:05 UTC, Inkrementator wrote:
> On Tuesday, 1 April 2025 at 23:01:23 UTC, Daniel Donnelly, Jr. 
> wrote:
>> Say I have a static context stack in my class Context, will 
>> each new thread receive their own copy of the static member or 
>> do I have to account for multiple threads and do it myself?
>
> All global variables in D, including static class members, are 
> thread local by default. You have to explicitly add the 
> `__gshared` attribute to the static variable to make it truly 
> global.

Thats a good thing.  The default is great for my app.


More information about the Digitalmars-d-learn mailing list