本文介绍了什么是"挥发性QUOT;用于关键字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了挥发性关键词一些文章,但我无法找出它的正确使用。你能告诉我它应该在C#和Java来用的?

I read some articles about the volatile keyword but I could not figure out its correct usage. Could you please tell me what it should be used for in C# and in Java?

推荐答案

有关C#和Java中,挥发性讲述一个变量的值必须永远不会被缓存为它的值可以外部改变的范围的编译器程序本身。然后,编译器将避免可能导致问题的任何的优化如果变量的变化。

For both C# and Java, "volatile" tells the compiler that the value of a variable must never be cached as its value may change outside of the scope of the program itself. The compiler will then avoid any optimisations that may result in problems if the variable changes "outside of its control".

这篇关于什么是"挥发性QUOT;用于关键字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-25 02:21