Python RuntimeError: thread.__init__() not called解決方法

字號(hào):


    這篇文章主要介紹了Python RuntimeError: thread.__init__() not called解決方法,需要的朋友可以參考下
    在寫一個(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è)使用的注意地方。