如何在循环中读取用户输入(并且不阻塞此循环中的工作)?
如何在循环中读取用户输入(并且不阻塞此循环中的工作)?
我想做一些基本的事情,比如切换 DEBUG 变量、在用户将打印的某些特定键上打印某些变量的值等,但我的程序在恒定循环中工作,并且该循环触发另一个线程。我该怎么做?
How to read users input when in loop (and without blocking work in this loop)?
I want to do some basic stuff, like switching DEBUG variable, print values of some variables etc on some specific keys that user will print, but my program work in constant loop, and this loop fire another threads. How can i do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用线程:(
由于两个循环都将内容打印到终端,输出在这里有点混乱,但我认为这个想法应该很清楚。)
Use threads:
(Output gets kind of messed up here because of both loops printing stuff to the terminal but I think the idea should be clear.)