how to make a thread python code example
Example 1: create new thread python
from threading import Thread
from time import sleep
def threaded_function(arg):
for i in range(arg):
print("running")
sleep(1)
if __name__ == "__main__":
thread = Thread(target = threaded_function, args = (10, ))
thread.start()
thread.join()
print("thread finished...exiting")
Example 2: python threading
def myFunction(x, y):
pass
x = threading.Thread(target=myFunction, args=(x, y))
x.start()