下面的函数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()
上面所示的“one obvious way to do it”行不通:thread.join()
返回None
。