目录
多线程队列,关闭
import threading
import time
import queue
class MatrixCopyThread(threading.Thread):
def __init__(self, helper_matrix, result_queue):
threading.Thread.__init__(self)
self.helper_matrix = helper_matrix
self.result_queue = result_queue
self.stop_event = threading.Event() # 使用 Event 来控制停止
def run(self):
while not self.stop_event.is_set(): # 检查 stop_event
helper_matrix_now = self.helper_matrix.copy()
self.result_queue.put(helper_matrix_now)