from threading import Thread
from time import sleep,ctime
#自定义线程类
class TheradClass(Thread):
def __init__(self,target=None,args=(),kwargs={}):
# 重写父类方法
super().__init__()
self.target = target
self.args=args
self.kwargs = kwargs
def run(self):
self.target(*self.args,**self.kwargs)
def player(sec,song):
for i in range(3):
print('Player%s:%s'%(song,ctime()))
sleep(sec)
a = TheradClass(target =player,args=(3,),kwargs={'song':'111'})
a.start()
a.join()