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

Inkrementator invalid at invalid.org
Thu Apr 3 18:45:50 UTC 2025


On Wednesday, 2 April 2025 at 08:38:32 UTC, Daniel Donnelly, Jr. 
wrote:
> On Wednesday, 2 April 2025 at 08:33:05 UTC, Inkrementator wrote:
>> 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.

Addendum: When you need non-thread-local global variable, look 
into `shared` instead of `__gshared` to see if it meets your 
needs.


More information about the Digitalmars-d-learn mailing list