Python多线程简单例子
import threading import Queue class Test(threading.Thread): def __init__(self, q): self.queue = q threading.Thread.__init__(self) def run(self): while True: event = self.queue.get() if event is None: break print str(event) queue = Queue.Queue(100) for i in range(10): t = Test(queue) t.start() for i in range(10): queue.put(i) for i in range(10): queue.put(None)