Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Wed Apr 25 17:34:42 2018
- @author: STUDENT
- """
- import queue, threading
- import random, time
- import matplotlib.pyplot as plt
- def losuj(x,nr, out_q):
- for i in range(5):
- r = random.randint(1,20)
- out_q.put(r)
- print("wylosowana liczba "+str(r))
- print("wylosowana liczba %s" % (str(nr)))
- time.sleep(x)
- out_q.put(None)
- print("zakonczył dzaiłanie"+str(nr))
- def wyniki(in_q):
- while True:
- n=in_q.get();
- if n is None:
- print("Zakończona praca")
- break
- print("wynik: "+str(n))
- def main():
- q=queue.Queue()
- t1= threading.Thread(target=losuj,args=(4,1,q))
- t2= threading.Thread(target=wyniki,args=(q,))
- t1.start()
- t2.start()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement