0
当使用多线程时,我得到组合数据
列表是:A,B,C。如果我MT,这个fdata []包含来自A,B和C的数据。我如何获得fdata也只保存一组数据。我试过del fdata没有帮助。我需要某种锁。如何使用python停止多线程返回组合数据
class WorkerThread(threading.Thread):
def __init__(self, queue):
threading.Thread.__init__(self)
self.queue = queue
def run(self):
while 1:
try: # take a job from the queue
symbol, test, test2 = self.queue.get_nowait()
except Queue.Empty:
raise SystemExit
fn = %s.CSV" % symbol
fdata = []
fo = open(fn, 'rb')
fr = csv.reader(fo, dialect='excel')
for row in fr:
fdata.append(row)
#print fdata
#del fdata
如何将线程号添加到fdata或列表ID为A,B,C到fdata?
这里的多线程究竟是什么?某种程度上你的fdata是全球性的吗? – Liorsion 2011-02-08 06:59:43
查看编辑 – Merlin 2011-02-08 15:12:38