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的」對象有沒有屬性「目標」
我如何解決此得到什麼?