Java and C 11 volatile
•
Java
I want to port some code from Java to C 11. I'm confused about volatile keyword
I'm not familiar with the Java language. I don't know what variables it is It ensures that each thread can access the latest value of the variable - it is C volatile behavior But it is usually used for synchronization – is it all the operations performed on volatile variable atoms?
So I think a good alternative to Java volatile in C 11 will be STD:: atomic Or am I completely wrong because I missed some additional Java volatile features?
Solution
Yes, they will be a good match. There is a good article in Dr Dobbs
Java provides such variables as volatile, and C is STD:: atomic
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码