我有下面的代碼,但後隊列爲空,它存在於任何見解:在Python中結束一個線程的生命?
def processor():
while(1>0):
if queue.empty() == True:
print "the Queue is empty!"
break
source=queue.get()
page = urllib2.urlopen(source)
print page
def main:
for i in range(threads):
th = Thread(target=processor)
th.setDaemon(True)
th.start()
queue.join()
它打印隊列空的,因爲很多次,因爲我有螺紋,只是站在那裏什麼都不做。
請修復縮進併發佈一個完整的示例。 – NPE 2011-06-03 12:26:16