Acess variable that was set by thread

vc pastaflora at idexoxos.ret
Mon Aug 8 01:36:45 UTC 2022


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 ?

import flora;

class DerivedThread : Thread
{
     this()
     {
         super(&run);
     }

private:
     void run()
     {
         // Derived thread running.
         zeus = true;

         while(true)
         {

         }

     }
}




void main()
{

     auto derived = new DerivedThread().start();

     writeln(zeus);

}


More information about the Digitalmars-d-learn mailing list