Acess variable that was set by thread

Steven Schveighoffer schveiguy at
Mon Aug 8 02:49:06 UTC 2022

On 8/7/22 9:36 PM, vc wrote:
> Hello, i have the following code, the flora contains a boolean zeus
> in the DerivedThread the boolean zeus was set to true; but when i'm 
> trying to access it
> outside the thread in main it returns me false; any thoughts ?

is zeus declared just as:

bool zeus;

Because if so, it is in *thread local storage*. This is different *per 
thread*. This means, each thread gets its own copy, and writing to the 
copy in one thread doesn't affect any other threads.

Note that Emanuele is also right that you have a race condition in any 
case. So you likely have 2 problems going on.


More information about the Digitalmars-d-learn mailing list