Re: JMM- synchronization access in a concrete example.

2018-09-26 Thread Tom Lee
Oops: "use x and y somehow" should read "use y and z somehow" in the example I gave. Hopefully that's not too confusing. On Tue, Sep 25, 2018 at 11:09 PM Tom Lee wrote: > How to interpret a citation given by Cezary?: "If x and y are actions of >> the same thread and x comes before y in program

Re: JMM- synchronization access in a concrete example.

2018-09-26 Thread Tom Lee
> > How to interpret a citation given by Cezary?: "If x and y are actions of > the same thread and x comes before y in program order, then hb(x, y)." This is a great question! Hopefully I'm not too far off-base but I think it comes down to effects/"visibility" and this statement hints at the

Re: JMM- synchronization access in a concrete example.

2018-09-25 Thread John Hening
Tom, Actually you right. I get it! Gil, thanks for your note. You obviously right. If I use multithreaded executor I got a lot races in a result. So, does it mean that my both version of example are correct? How to interpret a citation given by Cezary?: "If x and y are actions of the

Re: JMM- synchronization access in a concrete example.

2018-09-25 Thread Gil Tene
As Tom noted, The Executor's submission happens-before promise prevents a reordering of (1) and (2) above. Note that, as written, the reason you you don't have data races between (2) and (2) is that executor is known to be a single threaded executor (and will only run one task at a time).

Re: JMM- synchronization access in a concrete example.

2018-09-25 Thread 'Cezary Biernacki' via mechanical-sympathy
My guess because "If x and y are actions of the same thread and x comes before y in program order, then hb(x, y)." https://docs.oracle.com/javase/specs/jls/se8/html/jls-17.html#jls-17.4.5 On Tue, Sep 25, 2018 at 8:44 PM John Hening wrote: > (1) should happen before "executor.execute()" (because

Re: JMM- synchronization access in a concrete example.

2018-09-25 Thread John Hening
> > (1) should happen before "executor.execute()" (because they are on the > same thread), > It does not matter that they are executed on the same thread. I do not see cause here to HB relation was set up. -- You received this message because you are subscribed to the Google Groups

Re: JMM- synchronization access in a concrete example.

2018-09-25 Thread 'Cezary Biernacki' via mechanical-sympathy
Hi, I assume you are worried that (1) can be moved by the compiler below "executor.execute()" or on processors with weak memory models changes from (1) might not be fully visible to other threads when (2) is executed. I believe it is not going to happen, as (1) should happen before