question about visibility of jmm(java memory model) or jsr133
i had a question about visibility of jmm and which confused me a long time ,question discriber as follow :
as we know ,this is 6 actions defined when we read/write share variable between main momery and work copy of thread ,we just think work copy as cache,
we know when thread read a share variable ,the thread need to copy variable from monery to cache, "read-load-use", if the thread read the same variable manytime ,this is two different deal maybe use this variable from cache "use",or read variable from momery again "read-load-use" which decided by jvm,
an other way when thread write a variable , frist copy variable from memory to cache and write variable "assign-store-write",when
the thread write the same varibale manytime ,this is still two situation decided by jvm, write varible in cache manytime and fiush last
resulte to momony "assign",or write cahe and flush to memory again and again, “assgin-store-load”,
my question is we image this scenairo,the single thread read and write a share varibel (the variable in memory ) again and again,
how to jvm controll this situation, the thread write the varibale in cache ,but hadnot flush this variable to memory ,and this time thread read this memory but from memory ,beacuse of the new variable had‘t flush to memory,why this single thread know the variable had been changed and can read a correct value ?
best regard !