Alex wrote:

import core.thread;

class A
{
        Thread mThread;
        bool mStopped;
         this()
        {
                mThread = new Thread(&run);
                mThread.start();
        }
         void run()
        {
                while (!mStopped)
                {
                        //do stuff
                }
        }
        ~this()
        {
                mStopped = true;
                mThread.join();
        }
}
this code is invalid. when `~this()` is called, your `mThread` *may* already be dead -- this is how GC works. you *may* *not* access heap-allocated members in `~this()`, this is a bug. it may work sometimes, but it isn't guaranteed.

Reply via email to