有没有办法永久地“暂停”应用程序的主 python 线程?
我有一些代码可以触发两个线程
class start():
def __init__(self):
Thread1= functions.threads.Thread1()
Thread1.setDaemon(True)
Thread1.start()
Thread2= functions.threads.Thread2()
Thread2.setDaemon(True)
Thread2.start()
#Stop thread here
目前,当程序到达该函数的末尾时,它退出(之后主线程没有其他事情要做),杀死无限运行的线程(循环)。如何阻止主进程退出?我可以使用while True: None
循环来完成,但这会占用大量 CPU,而且可能有更好的方法。