O'Reilly logo
  • Dong Yu thinks this is interesting:

The issue here is that we potentially have a race condition because one piece of data is being shared between two different threads. In our first example, the race condition came about because the threads were accessing multiple pieces of data and there was no way to update all of them atomically without using the synchronized keyword. When only a single piece of data is involved, there is a different solution.

From

Cover of Java Threads, 3rd Edition

Note

the use scope