from queue import Queue
import threading
import time
# q = Queue(6)
#
# for x in range(6):
# q.put(x)
#
# for x in range(6):
# print(q.get())
#参数为队列
def set_value(q):
test = 0
while True:
q.put(test)
test += 1
time.sleep(0.5)
def get_value(q):
while True:
print(q.get())
def main():
q = Queue(6)
t1 = threading.Thread(target=set_value,args=[q])
t2 = threading.Thread(target=get_value,args=[q])
t1.start()
t2.start()
if __name__ == '__main__':
main()