You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
348 B

from threading import Lock, Thread
import time
def suma_uno():
global g
a = g
time.sleep(0.001)
g = a+1
def suma_tres():
global g
a = g
time.sleep(0.001)
g =a+3
g = 0
threads = []
for func in [suma_uno,suma_tres]:
threads.append(Thread(target=func))
threads[-1].start()
for thread in threads:
thread.join()
print(g)

Powered by Informatica FP.