from threading import Thread
import time
class MyThread(Thread) :
def __init__(self, a,b,c) :
self.a = a# 有几个参数,这里就写几行
self.b = b
self.c = c
.......
super(MyThread, self).__init__() #调用父类的构造方法
本文介绍了一个使用Python threading模块创建自定义线程类的例子。该类接受三个参数并在初始化过程中保存这些值。通过继承Thread基类并重写__init__方法实现。
from threading import Thread
import time
class MyThread(Thread) :
def __init__(self, a,b,c) :
self.a = a# 有几个参数,这里就写几行
self.b = b
self.c = c
.......
super(MyThread, self).__init__() #调用父类的构造方法

被折叠的 条评论
为什么被折叠?