Currently I am trying to understand synchronized in Java getting to this java doc example under synchronized statements the example with the class MsLunch and the two instance variables c1 and c2.
It states:
Suppose, for example, class
MsLunchhas two instance fields,c1andc2, that are never used together. All updates of these fields must be synchronized, but there's no reason to prevent an update ofc1from being interleaved with an update ofc2— and doing so reduces concurrency by creating unnecessary blocking.
To me this sounds like c1 and c2 are not allowed to be used together. That is the reason why both statements which are incrementing c1 and c2 have to be synchronized. But why do they say in the next sentence that there is no reson to prevent an update of c1 from being interleaved with an update of c2. This sentences makes absolutely no sense to me. First they say they are not used together and now it is ok to increment c1 while at the same time c2 is being incremented.
Can someone please elaborate this paragraph to me.
Bear in mind that I am no native English speaker and there could be in fact a language problem in understanding this issue.