0
请帮助我的代码与线程。它是这样对象没有属性
class MyThread(threading.Thread): # Create a class representing a thread of control
def __init__(self,target):
print 'thread created'
self.target = target
threading.Thread.__init__ (self)
def run (self):
print 'running thread '
while True:
self.target()
# Define class to allow thread to be stopped over time
def __init__ (self, target):
super(MyThread, self).__init__()
self._stop = threading.Event()
print "thread stopped"
def stop (self):
self._stop.set()
def stopped (self):
return self._stop.isSet()
然而,当我运行它,它抱怨该行self.target():“MyThread的”对象有没有属性“目标”
我如何解决此得到什么?