请问一下,我用 threading 创建了几个线程去同时运行几个 cmd 的命令,但是这几个命令是不会自己结束掉的,它们一直在运行,我想做成当我输入按键事件的时候结束掉这几个线程。
例如代码这样写:
for cmd in cmds:
th = threading.Thread(target=execCmd, args=(cmd,))
th.start()
threads.append(th)
例如代码这样写:
for cmd in cmds:
th = threading.Thread(target=execCmd, args=(cmd,))
th.start()
threads.append(th)