I am reading "Thinking in Java 4th Edition" right now and I have a question about one paragraph. (Page 832, in the Concurrency section)
volatile doesn’t work when the value of a field depends on its previous value (such as incrementing a counter), nor does it work on fields whose values are constrained by the values of other fields, such as the lower and upper bound of a Range class which must obey the constraint lower <= upper.
I don't understand what is "volatile doesn't work" and why keyword volatile has to consider other fields. Can you enlighten me or can you give me some example about it? Thank you very much!