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.
25 lines
536 B
25 lines
536 B
from threading import Lock, Thread
|
|
import threading
|
|
import time
|
|
|
|
def retirarDinero(retirar,lock):
|
|
with lock:
|
|
global dineroTotal
|
|
if dineroTotal == 0:
|
|
print("Saldo insuficiente")
|
|
else:
|
|
print("Dinero retirado")
|
|
dineroTotal = dineroTotal-retirar
|
|
|
|
|
|
|
|
lock = threading.Lock()
|
|
dineroTotal = 1000
|
|
retDinero = 200
|
|
|
|
for i in range(3):
|
|
t = threading.Thread(retirarDinero(retDinero,lock))
|
|
t2 = threading.Thread(retirarDinero(retDinero,lock))
|
|
t.join
|
|
t2.join
|
|
|