下面的函数foo
返回字符串'foo'
.如何获取线程目标返回的值'foo'
?
from threading import Thread
def foo(bar):
print('hello {}'.format(bar))
return 'foo'
thread = Thread(target=foo, args=('world!',))
thread.start()
return_value = thread.join()
上面显示的"一个显而易见的方法"是行不通的:thread.join()
返回None
.