...
If doSomething()
and stop()
are called from different threads, the stop()
method could fail to see the initialized thread
, even though doSomething()
was called earlier, unless there is a happens-before relationship between the two calls. If the two methods are invoked by the same thread, they automatically have a happens-before relationship and consequently cannot encounter this problem.
...
Relying on the Thread
class's sleep()
, yield()
, and getState()
methods for synchronization control can cause unexpected behavior.
Related Guidelines
...
...
Bibliography
...