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()
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

 

posted @ 2017-05-04 09:40  ezway  阅读(491)  评论(0编辑  收藏  举报