Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import threading
  2.  
  3. suma = 0
  4.  
  5. # Crea un bloqueador (o Lock):
  6. bloqueador = threading.Lock()
  7.  
  8.  
  9. def sumar():
  10.     global suma, bloqueador
  11.    
  12.     # Activa el bloqueador:
  13.     bloqueador.acquire()
  14.    
  15.     suma = suma + 1
  16.    
  17.     # Desactiva el bloqueador:
  18.     bloqueador.release()
  19.    
  20.  
  21. thread = threading.Thread(target=sumar)
  22. thread.start()