def run(self):
        """
        overload of threading.thread.run()
        main control loop
        """
        print "%s starts" % (self.getName(),)
        
        count = 0
        while not self._stopevent.isSet():
            count += 1
            print "loop %d" % (count,)
            self._stopevent.wait(self._sleepperiod)
        
        print "%s ends" % (self.getName(),)

        overload of threading.thread.run()
        main control loop
        
recipes/Python/65448_Thread_Control_Idiom/recipe-65448.py