在使用thread的时候,定义如下类:
class newThread(threading.Thread):
def __init__(self, threadID, name, counter):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self.counter = counter
注意:
"If the subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing
anything else to the thread."
也就是说子类的__init__()方法调用父类的__init__方法,一定要在第一行调用。否则会出标题上的错误!