...
It is important to note that neither
Thread.sleep
norThread.yield
have any synchronization semantics. In particular, the compiler does not have to flush writes cached in registers out to shared memory before a call toThread.sleep
orThread.yield
, nor does the compiler have to reload values cached in registers after a call toThread.sleep
orThread.yield
.
Code that depends bases its concurrency safety on thread suspension or that yields to processes that
- flush cached registers
- reload any values
- provide any happens-before relationships when execution resumes
...