25 lines
474 B
Python
25 lines
474 B
Python
import threading
|
|
|
|
def cube(n, name):
|
|
print("name : {0}".format(name))
|
|
print(f"Le cube: {n * n * n}")
|
|
|
|
def carre(n, name):
|
|
print("name : {0}".format(name))
|
|
print(f"Le carré: {n * n}")
|
|
|
|
|
|
threads = []
|
|
# création de thread
|
|
for i in range(0,10):
|
|
t1 = threading.Thread(target=carre, args=(3,"toto-{}".format(i)))
|
|
threads.append(t1)
|
|
|
|
|
|
for thread in threads:
|
|
thread.start()
|
|
thread.join()
|
|
|
|
|
|
# les deux thread sont exécutés
|
|
print("C'est fini!") |