Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: minor, see previous edit

...

Unlike the noncompliant code exampleexamples, if a and b currently have the value 0, and one thread calls getSum() while another calls setValues(1, 1), getSum() may return return 0, or 2, depending on which thread obtains the intrinsic lock first. The locking guarantees that getSum() will never return returns the unacceptable value 1.

...