Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import threading
- import queue
- class Main:
- def __init__(self):
- self.q()
- def main(self):
- while True:
- i = self.q.get()
- print(i)
- self.q.task_done()
- def t(self):
- for i in range(10):
- t = threading.Thread(target=self.main)
- t.daemon = True
- t.start()
- def q(self):
- self.q = queue.Queue()
- self.t()
- for i in range(100):
- self.q.put(i)
- self.q.join()
- if __name__ == '__main__':
- Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement