On Thu, Apr 24, 2014 at 8:24 AM, Sebastian Gesemann
On Thu, Apr 24, 2014 at 1:59 PM, Lee Clagett
wrote: I also programmed in Java. From what I can tell, there is little difference between Java and C++ in this regard. The terminology is just different. What you call "monitor", "volatile" and "happens before" in Java is called "mutex", "amotic" and "sequenced before". On top of that C++11 allows you to use "weaker synchronization". But that's something I choose to ignore because it's just too easy to get it wrong and not worth the performance gain in my opinion.
Volatile in C/C++ is not sequenced like atomics in Java. In many cases
the
observed behavior on x86 platforms will be similar, but this is by chance. C++11 and boost have std/boost::atomic, which will match the behavior of Java atomics. C++11 and boost also have a std/boost::mutex implementation.
Not sure whether this was meant as correction or you simply wanted to add your comment. Anyhow, I did not say anything about C++'s volatile. I tried to convey that the cases in which you would use volatile in Java are typically cases in which you would use atomics in C++.
Lee
Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Sorry I inverted your original sentence when I read it. Lee