当我执行这段代码
import class3,thread
t3 = class3.test3
thread.start_new_thread(t3.func3,())
class3
在哪里class test3(object):
def func3():
while 1:
print "working!!"
我收到一个错误:
Unhandled exception in thread started by <unbound method test3.func3>
此错误的含义是什么,我该如何解决?
最佳答案
调用它,看看会发生什么:
TypeError: unbound method func3() must be called with test3 instance as first argument (got nothing instead)
您要么必须使
func3
成为实例方法,然后初始化您的类:class test3(object):
def func3(self):
while True:
print "working!!"
t3 = test3()
或者将
func3
设为staticmethod
:class test3(object):
@staticmethod
def func3():
while True:
print "working!!"
关于multithreading - 排除 “unhandled exception in thread”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15626435/