從混亂重構我已經編輯了問題:線程和信息路過 - 如何
one.py
import threading
count = 5
dev = threading.Thread(name='dev', target=dev,args=(workQueue,count,))
dev.setDaemon(True)
dev.start()
workQueue = Queue.Queue(10)
queueLock.acquire()
workQueue.put(word)
queueLock.release()
count = 3
time.sleep(2)
count = 5
但在這裏,我的困惑是,我能夠從隊列中提出,並得到價值在線程之間,但在計數的情況下,它不反映。
這是爲什麼?
什麼是實際上在這裏失蹤?
class dev (threading.Thread):
def test(self):
while 1:
print count
print self.EPP_Obj
queueLock.acquire()
if not self.workQueue.empty():
data = self.workQueue.get()
print data
queueLock.release()
else:
queueLock.release()
def __init__(self, workQueue, EPP_Obj):
threading.Thread.__init__(self)
self.workQueue = workQueue
self.EPP_Obj = EPP_Obj
@all:我修改了一部分代碼..所以請忽略錯誤 – Ragav 2012-02-08 08:56:21
您究竟在哪裏遇到問題?爲什麼開發類不是'Thread'子類?你在追蹤什麼[線程教程](http://www.google.com/search?q=python+threading+tutorial)?他們通常涵蓋你所要求的。 – 2012-02-08 09:07:07
@ Rik Poggi:就像下面的代碼由阿諾德是我的需要,但我不想使用QUEUE機制來實現。只是想實現數據/對象通過線程lock.notify機制傳遞 – Ragav 2012-02-08 10:43:25