def work():
while not STOP:
# jobs in worker thread
STOP = False
for n in range(num):
workers.append(Thread(target=work))
workers[n].start()
try:
# jobs in main thread...
except KeyboardInterrupt:
STOP = True
for n in range(num):
workers[n].join()
題外話,Python multi-thread 跟 multi-process 的介面真的是簡單到一個不行,超好用的。

0 篇留言:
張貼意見