[concurrency-interest] final field/constructor visibility (cf. CyclicBarrier)

Justin Sampson jsampson at guidewire.com
Mon Sep 29 03:33:49 EDT 2014

Yuval Shavit wrote:

> > If [s2] is ordered before [s1], then [r] happens-before [w]
> I don't see why this is the case.  It would certainly be true if
> [s1] happened-before [w] and [r] happened-before [s2], but that's
> not the case.  Thread 1 will act as if hb(s1, w) because of same-
> thread semantics, and similarly for thread 2 acting as if hb(r,
> s2), but neither edge is established outside of its respective
> thread.

But isn't that exactly the point of happens-before, to establish
constraints between threads?  What happens _within_ a thread is
simply called "program order."  The very first rule in 17.4.5
establishes the relationship between program order and happens-
before order:  "If x and y are actions of the same thread and x
comes before y in program order, then hb(x, y)."  That is, program
order is subsumed within happens-before order.  But alone that's
not very interesting, because it still takes synchronization actions
and transitivity to actually introduce _constraints_ between
threads.  The existence of hb(x, y) for two actions of thread #1 is
irrelevant to thread #2, absent synchronization, simply because the
actions x and y are not actions of thread #2, not because the
relation hb(x, y) is established by another thread.


More information about the Concurrency-interest mailing list