Advertisement
markic99

PRVI

Jun 14th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. import threading
  2.  
  3.  
  4. produkt = 1
  5. lock = threading.Lock()
  6.  
  7.  
  8.  
  9. def mnozenje(x,y):
  10.  
  11. global produkt
  12.  
  13. lock.acquire()
  14.  
  15. for i in range(x,y):
  16.  
  17. produkt*=i
  18.  
  19. lock.release()
  20.  
  21. t1=threading.Thread(target=mnozenje, args=(1,750))
  22.  
  23. t2=threading.Thread(target=mnozenje, args=(751,1500))
  24.  
  25.  
  26. t1.start()
  27.  
  28. t2.start()
  29.  
  30.  
  31. t1.join()
  32.  
  33. t2.join()
  34.  
  35.  
  36. print (produkt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement