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('主线程')