博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
守护线程
阅读量:5090 次
发布时间:2019-06-13

本文共 740 字,大约阅读时间需要 2 分钟。

import timefrom threading import Threaddef func1():    while True:        print('*'*10)        time.sleep(1)def func2():    print('in func2')    time.sleep(5)t = Thread(target=func1,)t.daemon = Truet.start()t2 = Thread(target=func2,)t2.start()# t2.join()print('主线程')

 

import timefrom threading import Thread,Lockdef func():    print(666)    time.sleep(10)def func2():    passt = Thread(target=func)t.daemon = Truet.start()print('主线程')

 

import timefrom threading import Thread,Lockdef func():    while True:        print('*'*10)        time.sleep(1)def func2():    print('in func2')    time.sleep(5)t = Thread(target=func)t.daemon = Truet.start()t2 = Thread(target=func2)t2.start()print('主线程')

 

转载于:https://www.cnblogs.com/kuraki/p/9617319.html

你可能感兴趣的文章