I'm trying to learn/understand threading in python and found this. I tried to use this with input() but it doesn't work the way I imagined.
import queue
import threading
def cin(el, q):
while input() != el:
print('no')
continue
q.put(el)
checks = ['one', 'two']
q = queue.Queue()
for el in checks:
t = threading.Thread(target = cin, args = (el, q))
t.daemon = True
t.start()
s = q.get()
print(s)
I'm trying to run two threads who each have a while loop to check if the input() from console matches with one of the elements from the list. If it doesn't it waits for the next input. What happens is that only 'one'-thread, so the first element in the list works. After a lot of trys 'two'-thread works but the other doesn't. Where is the mistake? Can only one thread use the input()? Is it not possible to run two while-loops at the same time?