I have the following code. I need to pause and resume randomly 1 of the threads I know how to random choice but how to pause them and resume later the thread. I look around over the all answers nothing work for me, I try with lock the thread is not locking I try with event again I don't manage to pause the thread. Any help is welcome. I am not a python developer, I just do a project.
def fistLoop():
for x in range(0,10):
print(str(x) + " this is first loop")
time.sleep(10)
def secondLoop():
for x in range(10,20):
print(str(x) + " second loop")
time.sleep(10)
first = threading.Thread(target=fistLoop, args=())
second = threading.Thread(target=secondLoop, args=())
threadList = list()
first.start()
second.start()