# -*- coding: utf-8 -*-
import threading
import thread
import time
class Test(object):
def __init__(self):
# threading.Thread.__init__(self)
self._sName = "machao"
def process(self):
#args是关键字参数,需要加上名字,写成args=(self,)
th1 = threading.Thread(target=Test.buildList, args=(self,))
th1.start()
th1.join()
def buildList(self):
while True:
print "start"
time.sleep(3)
test = Test()
test.process()
python中如何对类的成员函数开启线程
最新推荐文章于 2025-05-05 17:15:36 发布
本文介绍了一个使用Python实现的简单多线程示例。该示例创建了一个名为Test的类,通过调用该类的方法启动了一个无限循环的线程,每3秒打印一次消息。这个例子有助于理解如何在Python中利用threading模块来创建和管理线程。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
HunyuanVideo-Foley
语音合成
HunyuanVideo-Foley是由腾讯混元2025年8月28日宣布开源端到端视频音效生成模型,用户只需输入视频和文字,就能为视频匹配电影级音效
318





