python 线程继承类方法
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()
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()