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?
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?
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.
Threads are kept in a separate registry in the Python runtime, and you can "see" them by calling threading.enumerate (https://docs.python.org/3/library/threading.html#threading.enumerate) -
this is no different then not keeping a reference to a thread started in any other way.