我有这个示例代码:
import threading
from Queue import Queue
q = Queue(maxsize=0)
def work(q):
#do a job
for line in file_of_100_line:
q.put(line)
nbThreads = 2
for i in range(nbThreads):
t = threading.Thread(target=work, args=(q))
t.setDaemon(True)
t.start()
如果线程超过" x"我希望线程结束。秒执行。我怎么能用多线程做到这一点?感谢