在寫(xiě)一個(gè)多線程類的時(shí)候調(diào)用報(bào)錯(cuò)
RuntimeError: thread.__init__() not called
class NotifyTread(threading.Thread):
def __init__(self, params):
threading.Thread.__init__(self) #here。。。。。。
self.params = params
def run(self):
print "start notify............"
time.sleep(10)
print notify_tran(self.params)
print "end notify.............."
在init中要先初始化Thread,然后在給參數(shù)賦值,就能解決了。
也就是不能缺少
threading.Thread.__init__(self)
這是一個(gè)使用的注意地方。