Python threading.Thread minimal example
This example shows how to subclass and start a threading.Thread
:
#!/usr/bin/env python3
import threading
class MyThread(threading.Thread):
def run(self):
print("My thread!")
my_thread = MyThread()
my_thread.start()
print("Main thread")
This will print
My thread!
Main thread
(it might also print Main thread
first, depending on what gets executed first)