I use some multi-threading in my python application. I want to know what happens to a thread object after it finishes executing the "target" python method. Is it destroyed?
def speak():
#codes
thread = threading.Thread(target=speak, args=())
thread.start()
A simple test shows that the thread is still in memory, "stopped" after it finishes its process:
import threading
def speak():
pass
thread = threading.Thread(target=speak, args=())
thread.start()
thread.join() # wait for the process to finish;
print thread
# Result: <Thread(Thread-1, stopped 21864)>
From the documentation: "Python’s Thread class supports a subset of the behavior of Java’s Thread class; currently, there are no priorities, no thread groups, and threads cannot be destroyed, stopped, suspended, resumed, or interrupted."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With