python - 杀死线程不起作用

标签 python multithreading python-multithreading

我对线程进行了简单的调用:

aThread = threading.Thread(target=singleDriverThread, args=(d[0]))

然后我启动它(aThread.start)

当我需要停止线程时,我会这样做:

aThread.join()

但是线程继续运行..帮助?

最佳答案

如果你想停止一个线程,你应该杀死该线程或向该线程发出信号。这个SO answer还有这个SO answer处理停止线程。 join 方法仅等待线程退出。

一般来说,为了使线程正常停止,与其建立通信 channel 以便可以传递停止消息/信号是很有用的。

关于python - 杀死线程不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41682899/

相关文章:

python watchdog监视远程机器上的目录更改

python - 类中的 Thread.__init__(self) 如何工作?

.net - 多线程资源争用

python - 为什么 multiprocessing.Queue 没有 task_done 方法

python - Django将进度保存到下标的Session中

python - 如何将 super() 与一个参数一起使用?

python - 如何解决 Python 线程中这种奇怪的 MySQL 锁定行为?

python - 从列表中过滤字符串

java - ExecutorService hibernate 线程池中的所有线程

python - 在dtor python上加入线程