Occurs before the relationship in the JAVA memory model
With regard to JLS ch17 threads and locks, it says "if an action occurs before another action, the first action is visible before the second action and ordered before the second action"; I want to know:
(1) What does it really mean to say "order before"? Because even if action_ A occurs in action_ B before, action_ A can also be in action_ B in some subsequent implementations, right?
(2) If action_ A occurs in action_ Before B, does it mean action_ A never see action_ b? Or action_ A may or may not see the action_ b?
(3) If action_ A does not occur – in action_ B before and action_ B not happening – in action_ Before a, does it mean action_ A may or may not see the action_ b?
(4) There hasn't been any cycle before, has there?
Any answers will be appreciated:)
Solution
Before it happens, it is causality, not time action_ A in action_ B performs causal sorting before it, regardless of whether it is actually executed before it However, in practice, it is difficult for runtime to maintain causality without chronological order Check my earlier question, which details the topic of causality
Actions have a clear overall order of visibility to the other party This is handled by specifying well - formed execution parts Therefore, for any two actions a and B, a is visible to B, B is visible to a, or none of the above A good reader for understanding well constructed execution concepts is JAVA memory model examples: good, bad, and ugly
Yes, both are possible There is no guarantee whatsoever
Happens before must impose partial sorting, and the key attribute of sorting is acyclic