简体   繁体   English

将变量从一个线程输出到另一个线程

[英]Outputting variable from one thread to other

I have a thread that has an infinite loop running, updating a variable constantly.我有一个无限循环运行的线程,不断更新变量。 How can I access the live value of that variable in an another thread/outside of the thread (without being in an infinite loop)?如何在另一个线程/线程外访问该变量的实时值(不处于无限循环中)?

the best way to do it is to use global variables.最好的方法是使用全局变量。 But, you need to be aware of the lock conditions when threads are reading and writing to one variable at once.但是,您需要注意线程同时读取和写入一个变量时的锁定条件。

There is a good manual for example. 例如,有一本很好的手册。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从网站解析链接,并将特定链接输出为 Python 中的变量 - Parsing links from website, and outputting a specific one as variable in Python 在python中暂停一个线程 - Pause one thread from other in python 有没有一种方法可以从另一个文件中的一个文件中查找单词,并在新文件中输出在另一个文件中找不到的单词? - Is there a way of looking for words from one file in another file and outputting the words not found in the other file, in a new file? 从一个函数调用变量到另一个函数(Python) - Calling a variable from one function to the other (Python) 模型中的Django变量未在模板中输出值 - Django variable from Model not outputting value in template 使用 asyncio 从 websockets 输出变量的更好方法? - Better way of outputting variable from websockets with asyncio? 一个线程不会影响另一个线程? - One thread does not effect another other thread? 从 Python 中的一个线程读取值:队列还是全局变量? - Read value from one thread in Python: queue or global variable? 如何在OpenERP7中将变量从一个视图发送到另一个视图? - How to send a variable from one view to other one in OpenERP7? 如何将变量从一个python脚本传递给另一个python脚本? - How to pass a variable from one python script to an other one?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM