Comment exécuter la fonction sur différents threads Python
from threading import Thread
import time
def parallelFunc():
for i in range(100):
print("1")
time.sleep(0.2)
def parallelFunc2():
for i in range(100):
print("2")
time.sleep(0.2)
th = Thread(target=parallelFunc)
th2 = Thread(target=parallelFunc2)
th.start()
th2.start()
#Run code in parallel with other 2 functions
th.join()
th2.join()
#2 functions will loop at the same time
Said HR