Acess variable that was set by thread

vc pastaflora at idexoxos.ret
Mon Aug 8 07:14:33 UTC 2022

On Monday, 8 August 2022 at 02:49:06 UTC, Steven Schveighoffer 
> 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:
> ```d
> 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.
> -Steve

yes it is declared as

  bool zeus;
it seems change it to working is working

  __gshared bool zeus;

but as I'm new in to D, i will like to hear thoughts even if it 
works for me

More information about the Digitalmars-d-learn mailing list