Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import threading
- suma = 0
- # Crea un bloqueador (o Lock):
- bloqueador = threading.Lock()
- def sumar():
- global suma, bloqueador
- # Activa el bloqueador:
- bloqueador.acquire()
- suma = suma + 1
- # Desactiva el bloqueador:
- bloqueador.release()
- thread = threading.Thread(target=sumar)
- thread.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement