Answer the question
In order to leave comments, you need to log in
Why do streams in the console work differently than in the terminal?
the simplest example
from queue import Queue
from threading import Thread
def worker(q,n):
while True:
item = q.get()
if item is None:
break
print(item , n)
c = Queue()
th1 =Thread(target = worker,args = (c,1))
th2 =Thread(target = worker,args = (c,2))
th1.start()
th2.start()
for i in range(50):
c.put(i)
c.put(None)
th1.join()
c.put(None)
th2.join()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question