【问题标题】:what does threading.Thread do?threading.Thread 是做什么的?
【发布时间】:2014-08-05 03:19:16
【问题描述】:

我这里有这段代码:

t = theading.Thread(target = arping)
t.start()

有人可以向我解释一下 threading.Thread 是做什么的吗? 我知道这似乎是一个愚蠢的问题,但我不明白这一行。

【问题讨论】:

  • 阅读 Python 文档说明了什么?

标签: python


【解决方案1】:

该行创建了threading.Thread 类的实例。详情请见here

【讨论】:

    【解决方案2】:

    t = threading.Thread(target = arping) 行创建了一个threading.Thread 类,并通过类run() 方法调用arping

    基本上,这意味着脚本将在一个新的单独线程中运行arping 函数。

    第二行t.start()实际上启动了线程,该线程依次调用run()方法,该方法将运行arping可调用对象。

    关于线程的概念,你可以阅读更多关于它的信息here

    正如 tbrisker 所说,您可以在python docs 上获得更多信息。

    【讨论】:

      猜你喜欢
      • 2016-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-16
      • 2011-11-01
      • 2010-11-24
      • 2015-04-27
      • 2012-02-28
      相关资源
      最近更新 更多