I have this code and I run it with a thread but I want to kill it after 1 second '''
import threading
import time
def run(stop):
for i in range (10):
print(i)
time.sleep(0.3)
def main():
stop_threads = False
t1 = threading.Thread(target = run, args =(lambda : stop_threads, ))
t1.start()
time.sleep(1)
stop_threads = True
t1.join()
main()*