python线程只能启动一次_Python线程:只启动一个线程

而不是thread.start_new_thread(target=self.socketFunctionRead1())

尝试thread.start_new_thread(target=self.socketFunctionRead1)

因为有圆括号,函数被调用,函数的返回值被分配给target。由于thread.start_new_thread(target=self.socketFunctionRead1())可能是一个阻塞调用,因此只调用此函数。在

在thread.start_new_线程,目标应该是可调用的(一个行为类似于函数的对象)。在

编辑:thread.start_new_thread(function, args[, kwargs])

Start a new thread

and return its identifier. The thread executes the function function

with the argument list args (which must be a tuple). The optional

kwargs argument specifies a dictionary of keyword arguments. When the

function returns, the thread silently exits. When the function

terminates with an unhandled exception, a stack trace is printed and

then the thread exits (but other threads continue to run).

这意味着你应该打电话thread.start_new_线程(self.socketFunctionRead1). 在

如果您将关键字参数传递给start_new_thread,它们将被传递到self.socketFunctionRead1. 在

线程的目标是必需的,而不是关键字参数。在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值