Python线程isAlive方法

来源:互联网 发布:淘宝图片拍摄 编辑:程序博客网 时间:2024/05/20 13:40
__author__ = 'LL_YING''''线程创建之后,可以使用Thread对象的isAlive方法查看线程是否运行,为True则运行'''import threadingimport timeclass myThread(threading.Thread):    def __init__(self, num):        threading.Thread.__init__(self)        self.num = num    def run(self):        time.sleep(5)        print(self.num)def func():    t.start()    print(t.isAlive())t = myThread(1)func()t = myThread(1)# 输出# True# 1
0 0
原创粉丝点击