...
This noncompliant code example uses a shutdown()
method to set a non-volatile done
flag that is checked in the run()
method. If one thread invokes the shutdown()
method to set the flag, it is possible that another thread might not observe this change. Consequently, the second thread may still observe that done
if is false
and incorrectly invoke the sleep()
method.
...