1

for example

def thread1func():
    while True:
        tS = time.time()
        time.sleep(4)
        print(time.time() - tS)
def thread2func():
    i=0
    while True:
        tS = time.time()
        time.sleep(1)
        print(time.time() - tS)
        i += 1
        if i ==3:
            thread1._stop()#<----- how do I do this
            some_code
            some_code
            thread1.start()
thread1 = threading.Thread(target=thread1func)
thread2 = threading.Thread(target=thread2func)
thread1.start()
thread2.start()

I hope it's clear, what I want to know is how do I call a run/stop thread from another thread

0 Answers0