For example, the semantics of volatile are not strong enough to make the increment operation (x++) atomic, unless you can guarantee that the variable is written only from a single thread.Atomicity of ++ on volatile variables (or non-volatile for that matter) is not guaranteed. volatile x ++ is treated as load x, add 1, store x. A second thread doing x ++ could interleave, causing x to be incremented only once.
Java Concurrency in Practice
|
|
available on the web at: |
http://mindprod.com/jgloss/volatile.html |
optional Replicator mirror
|
J:\mindprod\jgloss\volatile.html | |
![]() |
Please email your
feedback for publication,
letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear
wording, broken/redirected link reports, suggestions to improve this page or comments to
Roedy Green :
| |
| Blog | Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[54.234.67.55] |
|
| Feedback | You are visitor number 257,433. | |