Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Wed Apr 25 17:34:42 2018
  4.  
  5. @author: STUDENT
  6. """
  7.  
  8. import queue, threading
  9. import random, time
  10. import matplotlib.pyplot as plt
  11.  
  12.  
  13. def losuj(x,nr, out_q):
  14. for i in range(5):
  15. r = random.randint(1,20)
  16. out_q.put(r)
  17. print("wylosowana liczba "+str(r))
  18. print("wylosowana liczba " % (str(nr)))
  19. time.sleep(x)
  20. out_q.put(None)
  21. print("zakonczył dzaiłanie"+str(nr))
  22.  
  23.  
  24. def wyniki(in_q):
  25. while True:
  26. n=in_q.get();
  27. if in_q.empty():
  28. print("Zakończona praca")
  29. break
  30. print("wynik: "+str(n))
  31.  
  32. if event.isSet():
  33. event.clear()
  34. print("wynik: "+ str(n))
  35.  
  36.  
  37.  
  38.  
  39. def main():
  40.  
  41. q=queue.Queue()
  42. t1= threading.Thread(target=losuj,args=(4,1))
  43. t2= threading.Thread(target=wyniki,args=(3,2))
  44. t1.start()
  45. t2.start()
  46.  
  47. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement