【发布时间】:2020-08-07 00:53:04
【问题描述】:
(Python 3.8.3)
我现在使用两个 python 线程,一个有一个 while True 循环
import threading
def threadOne():
while True:
do(thing)
print('loop ended!')
t1=threading.Thread(threadOne)
t1.start()
另一个检查 ctrl+r 输入。收到后,我需要第二个线程告诉第一个线程从 while 循环中中断。有没有办法做到这一点?
请注意,我无法将循环更改为“while Break == False”,因为 do(thing) 等待用户输入,但我需要将其中断。
【问题讨论】:
标签: python python-3.x multithreading