擅长:python、mysql、java
<p>在尝试设置名称之前,必须调用<code>__init__()</code>。线程名称是一个属性,而不是普通属性,它的setter检查对象是否已经初始化。另外,您不需要手动指定名称,因为<code>Threading.__init__</code>已经有name参数。所以:</p>
<pre><code>class myThread(threading.Thread):
def __init__(self, threadID, name, counter):
super(myThread, self).__init__(name=name)
self.threadID = threadID
self.counter = counter
#...
</code></pre>