The write thread.testValue = false has no "happens before" ordering with the read of thread.testValue , ie the write is not guaranteed to have occurred in the other thread (visibility) before ANY read in the other thread as the code stands.
I like to think of each thread running in its own plain of reality weekly linked.
If your really interested in this subject have a look at something called terracota which is
Java / memory model compliant you can run that program as written (with a bit of XML config) such that it will/can run each thread on a seperate JVM / physical machine now obviously each has a different physical memory but it uses "happens before ordering" as it has to to be JSR133 complient to allow threads to communicate.
So in your example your code (assuming threads on different machines) will ALWAYS fail BUT changing the variable to volatile ... the volatile write thraed.testValue = false will (if required) push the boolean value change between machines over the network and your code now always works ;-) which is why I keep think about its use purely for
testing purposes as a lot of the unit test code I have seen that supposedly tests multithreaded code looks flawed to me personally.
"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5