Python 一旦我删除了类实例,我的线程会自杀吗?

Python 一旦我删除了类实例,我的线程会自杀吗?,python,multithreading,class,Python,Multithreading,Class,在类实例中,我启动一个线程并将其自身添加到列表中。如果我从列表中删除类实例,线程会停止吗 SESSIONS = [] session(5) # Do some other stuff... SESSIONS.remove(x) # remove created instance class session: def __init__(self, timeValue): self.timeValue = timeValue threading.Threa

在类实例中,我启动一个线程并将其自身添加到列表中。如果我从列表中删除类实例,线程会停止吗

SESSIONS = []
session(5)
# Do some other stuff...
SESSIONS.remove(x) # remove created instance

class session:

    def __init__(self, timeValue):
        self.timeValue = timeValue
        threading.Thread(target=self.updateTime).start()
        SESSIONS.append(self)

    def updateTime(self):
        while True:
            time.sleep(1)
            self.playtime += 1

否。线程实例不是线程。实例只是一个句柄,您的程序可以使用它来询问线程的状态,并与线程交互