Skip to main content
 首页 » 编程设计

Python线程,杀死线程

2024年10月25日10powertoolsteam

<分区>

我只想激活一个线程,算法如下:

def myfunction(update): 
    if threading.activeCount >=1: 
        # kill all previous threads 
    while true: 
        # some execution 
 
 
while true: 
    t = threading.Thread(myfunction, args=([update])) 
    t.start() 

所以在这里线程在我的函数中进入无限循环,所以在开始新的之前我需要关闭前一个,请指导我