这些线程中的每一个都在不同的数据对象列表中搜索序列号。如果找到它,它会将对象放入队列中。序列号是唯一的。
q = Queue.Queue(10)
thread_list = []
for i in range(0, 10):
t = Thread(serial)
thread_list.append(t)
t.start()
而不是等待所有线程完成:
for t in thread_list:
t.join()
当找到它正在寻找的序列号时,有什么方法可以停止所有线程?并考虑到它可能找不到序列号并且队列将保持为空的可能性?