__author__ = "Alex Li"
import threading
import time
class MyThread(threading.Thread):
def __init__(self, n, sleep_time): # 重构构造函数
super(MyThread, self).__init__() # 继承父类构造函数
self.n = n
self.sleep_time = sleep_time
# 定义每个线程需要执行的函数
def run(self):
print("runnint task ", self.n)
time.sleep(self.sleep_time)
print("task done,", self.n)
start_time = time.time()
t1 = MyThread("t1", 2)
t2 = MyThread("t2", 4)
t1.start()
t2.start()
# t1.join() #=wait()
# t2.join()
#
# print("cost:",time.time() - start_time)
# print("main thread....")