Do i have to do a stop() function myself?

Ok i did a stop() function and i called when my class is not needed any more. But guess what: It doesnt stops the thread. My head is starts to blow up.

class ReplicatorServer: Replicator {
        public:
                this() {
                        Thread thread=new Thread(&threadFunc);
                        running=true;
                        thread.start();
                }
                
                void stop() {
                        running=false;
                        writeln("STOPPED");
                }
                
        private:
                bool running=false;
                int someVariable=1;
                
                void threadFunc() {
                        while(running) {
                                someVariable++;
                                //Thread.yield();
                        }
                }
                
}

Is threre something i dont understand with the concept here?? Becouse when i call Thread.yield() (in the threadFunc) repeatly, the class exists as normal.
Is running a thread local variable (their address is the same..)


Reply via email to