import time
from threading import Thread
from multiprocessing import Process #守护进程:主进程代码执行运行结束,守护进程随之结束 #守护线程:守护线程会等待所有非守护线程运行结束才结束 def f1():
time.sleep(2)
print('1号线程')
def f2():
time.sleep(3)
print('2号线程') if __name__ == '__main__':
t1 = Thread(target=f1,)
t2 = Thread(target=f2,)
# t1.daemon = True
t2.daemon = True
t1.start()
t2.start()
print('主线程结束')
# t1 = Process(target=f1, )
# t2 = Process(target=f2, )
# t1.daemon = True
# # t2.daemon = True
# t1.start()
# t2.start()
#
# print('主进程结束')