RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
threadingTread属性

name,ident,is_active参数的演示

import threading
import time

def worker():
    count = 0
    while True:
        if count > 5:
            break
        time.sleep(2)
        count += 1
        print(threading.current_thread().name)

t = threading.Thread(target=worker, name="worker")
print(t.ident)
t.start()

while True:
    time.sleep(1)
    if t.is_alive():
        print('{} {} alive'.format(t.name, t.ident))
    else:
        print('{} {} dead'.format(t.name, t.ident))

网站栏目:threadingTread属性
标题URL:http://scyingshan.cn/article/pdhpgs.html