I have a simple Python3 code, i want to start both function but just only "from_1" ran. Question: how can i manage two threads without .sleep() function, is Python have something to manage.
import threading
def from_1():
i = 1
while True:
print("Thread 1 {}".format(i))
f = open('face1.jpeg','rb')
img = f.read()
f = open('face1_w.jpeg','wb')
f.write(img)
f.close()
i += 1
def from_2():
i = 1
while True:
print("Thread 2 {}".format(i))
f = open('face2.jpeg','rb')
img = f.read()
f = open('face2_w.jpeg','wb')
f.write(img)
f.close()
i-= 1
if __name__ == '__main__':
jobs = []
threading.Thread(from_1()).start()
threading.Thread(from_2()).start()