for i in range(0, 5):
    t = ProcessThread(pathqueue, resultqueue)
t.setDaemon(True)
t.start()
t = PrintThread(resultqueue)
t.setDaemon(True)
t.start()
for path in paths:
    pathqueue.put(path)
pathqueue.join()
resultqueue.join()
python - appending to same file from multiple threads