What happens to thread started in the class instance when all references to the instance are destroyed (Python)?

Viewed 63

Question is in the title.

Code example:

class A:
    def start_thread(self):
        t1 = threading.Thread(target=something)
        t1.start()

a = A()
a.start_thread()
a = A()

So, what happens to the thread, which we started?

2 Answers

The threading module itself keeps a reference to each active Thread object, so a running thread will continue to run even if the reference goes away.

Related