acceptable answers after looking @ answers, comments , jls-17.4.2
1) anti-symmetric property holds pointed - user3707125
2) hb relationship between locks between unlocking , locking hb(ul, l) not same hb(l, ul). hinted - shmosel
jsl -
an unlock on monitor happens-before every subsequent lock on monitor.
3) , reasonable explanation of hb james-large
actual question was:
the java memory model(jmm) describes happens before relationships between several actions. if "x" , "y" 2 actions h(x,y) relation between them. jmm states implementations (compiler, run time or hardware) free re-order these executions if achieve same result executing "x" , "y" sequentially.
so think that,
hb(x,y) != hb(y,x)
am right? or did miss something?
update:
actions involve locks how can hb relation established. event of locking different threads can not defined program order, , not deterministic , depends on several factors instructions , scheduler etc.
between 2 locking actions - l1 , l2 how define relationship hb(l1, l2) or hb(l2, l1). seems both acceptable. in case both seems equal.
l1 , l2 locking actions on same object. l1 , l2 not locks
clarification (based on comments): locking actions mutually exclusive when locking done on same object different threads.
yes, implementation allowed reorder operations, within reasonable limits. happens before relationships defined in java language specification (jls) there define limits of can reordered.
if jls says x happens before y, means implementation not allowed reordering create appearance of y happening before x.
Comments
Post a Comment