Skip to content

Instantly share code, notes, and snippets.

@SeavantUUz
Created November 8, 2015 11:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save SeavantUUz/68ee6cb1c59822c7d5e3 to your computer and use it in GitHub Desktop.
import time
from threading import Event
from queue import Queue
import threading
q1 = Queue()
q2 = Queue()
class H(object):
def __init__(self):
self.event = Event()
self.q = q1
def set_queue(self, queue):
print('hehe')
self.q = queue
def run(self):
while self.event:
a = self.q.get()
print(a)
time.sleep(0.5)
def run(ins):
ins.run()
def set_queue(a):
a.set_queue(q2)
for i in range(10):
q1.put(1)
q2.put(20)
a = H()
b = threading.Thread(target=run, args=(a,))
b.start()
time.sleep(2)
set_queue(a)
print('hehehehe')
b.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment