【发布时间】:2014-04-22 16:11:16
【问题描述】:
我有点困惑。
我正在尝试在循环中启动一个线程,即:
while True:
my_thread.start()
我有点困惑,因为我已经让它与my_thread.run() 一起工作,但是当我将它换成 start() 时,它无法启动多个线程。我的 .run() 实际上不是一个单独的线程,如果不是,我应该做什么 ?最后,我可以将变量传递给 start() 吗?
【问题讨论】:
-
您是否阅读过这些方法的文档?
-
是的,但我很难找到合适的例子来解释这些概念。
-
docs.python.org/2.7/library/threading.html#module-threading
start(): Start the thread’s activity. [...] run() method (is) invoked in a separate thread of control.VSrun(): Method representing the thread’s activity. -
这很有帮助,谢谢。
标签: python multithreading