I was going through Java: Concurrency in Practice, and in the third chapter, the authors write:
"...There is no guarantee that operations in one thread will be performed in the order given by the program, as long as the reordering is not detectable from within that thread—even if the reordering is apparent to other threads...."
I understand that the actual order of execution of statements in one thread might not be what was written in the program (depends upon compiler optimisations and stuff). But for some reason, I cannot decipher the arcane statement written by the authors.
"...There is no guarantee that operations in one thread will be performed in the order given by the program..."-Alright. The actual order of execution of statements might differ.
"...as long as the reordering is not detectable from within that thread—even if the reordering is apparent to other threads..."-What do they mean by "....detectable from within the thread...."?