python 线程继承类方法

mac2022-06-30  25

def gg(): print(time.time()) return time.time() t1=threading.Thread(target=gg,) t2=threading.Thread(target=gg,) t2=threading.Thread() t1.start() t2.start() View Code

 

import time,threading class Mythread(threading.Thread): def __init__(self,num): threading.Thread.__init__(self) self.num=num def run(self): print('running number %s'% self.num) print(time.asctime()) time.sleep(3) if __name__== '__main__': t1= Mythread(1) t2= Mythread(2) t1.start() t2.start() View Code

 

转载于:https://www.cnblogs.com/ezway/p/6805380.html

最新回复(0)