Reputation: 93
here my issue. I have a mainApplication (c++ application) which launches K threads (c++ threads) at the application starts. Each thread has its own configuration. All k threads load the same Dll (myDll.dll) which has a static var X. Inside each thread, i have a function that prints the X address, and all threads print the same address value for X. So my question is: Is static var X, declared into Dll, shared between all threads? I use windows and c++. Kind regards.
Upvotes: 0
Views: 40
Reputation: 12496
Yes. Read this: https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-data#variable-scope
Basically, threads are not isolated from each other in any way, shape or form -- all threads in a program operate on the same memory. This notion extends to DLLs as well.
Upvotes: 1