python method use thread 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 thread function
x = threading.Thread(target=thread_function, args=(1,), daemon=True)
x.start()
# x.join()