码迷,mamicode.com
首页 > 编程语言 > 详细

守护线程

时间:2018-06-01 13:26:09      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:threading   主线程   done   守护线程   run   sleep   tar   time   pre   

import threading,time

def run():
time.sleep(3)
print(‘哈哈哈‘)


for i in range(50):
t = threading.Thread(target=run)
t.setDaemon(True) #把子线程设置成守护线程 (主线程一死,守护线程就死)
t.start()

print(‘Done,运行完成.‘)
time.sleep(3)



守护线程

标签:threading   主线程   done   守护线程   run   sleep   tar   time   pre   

原文地址:https://www.cnblogs.com/jiadan/p/9120859.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!