Python 3中thread.start_new_thread发生了什么 [英] What happened to thread.start_new_thread in python 3
本文介绍了Python 3中thread.start_new_thread发生了什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我喜欢将函数变成线程的能力,而不必使用不必要的代码来定义类.我了解_thread,但是似乎您不应该使用_thread.在python 3中是否有与thread.start_new_thread等效的良好实践?
I liked the ability to turn a function into a thread without the unnecessary line to define a class. I know about _thread, however it appears that you are not supposed to use _thread. Is there a good-practice equivalent of thread.start_new_thread for python 3?
推荐答案
threading.Thread(target=some_callable_function).start()
或者如果您希望传递参数,
or if you wish to pass arguments,
threading.Thread(target=some_callable_function,
args=(tuple, of, args),
kwargs={'dict': 'of', 'keyword': 'args'},
).start()
这篇关于Python 3中thread.start_new_thread发生了什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文