Re: Happens before between putting and getting from and to ConcurrentHashMap

2018-11-18 Thread Michael Barker
And optimising compilers. On Mon, 19 Nov 2018, 10:45 Dr Heinz M. Kabutz Or get rid of pipelining and caches ... :-D > > On Sun, 18 Nov 2018 at 23:21, Kodewerk wrote: > >> This is all too confusing… can’t you just single thread everything? >> >> — Kirk >> >> >> On Nov 18, 2018, at 10:35 AM,

Re: Happens before between putting and getting from and to ConcurrentHashMap

2018-11-18 Thread Dr Heinz M. Kabutz
Or get rid of pipelining and caches ... :-D On Sun, 18 Nov 2018 at 23:21, Kodewerk wrote: > This is all too confusing… can’t you just single thread everything? > > — Kirk > > > On Nov 18, 2018, at 10:35 AM, Vladimir Sitnikov < > sitnikov.vladi...@gmail.com> wrote: > > Jean-Philippe>is a write

Re: Happens before between putting and getting from and to ConcurrentHashMap

2018-11-18 Thread Kodewerk
This is all too confusing… can’t you just single thread everything? — Kirk > On Nov 18, 2018, at 10:35 AM, Vladimir Sitnikov > wrote: > > Jean-Philippe>is a write to value but no read of this value inside the same > thread, so the write is free to be reordered > > It ("reordering") does

Re: Happens before between putting and getting from and to ConcurrentHashMap

2018-11-18 Thread John Hening
Gil and Vladimir, thanks a lot for your time and explanation. This discussion was very fruitful, at least for me. W dniu niedziela, 18 listopada 2018 19:35:30 UTC+1 użytkownik Vladimir Sitnikov napisał: > > Jean-Philippe>is a write to value but no read of this value inside the > same thread,

Re: Happens before between putting and getting from and to ConcurrentHashMap

2018-11-18 Thread Vladimir Sitnikov
Jean-Philippe>is a write to value but no read of this value inside the same thread, so the write is free to be reordered It ("reordering") does not really matter. For instance, 17.4.5. Happens-before Order> If the reordering produces results consistent with a legal execution, it is not illegal.

Re: Happens before between putting and getting from and to ConcurrentHashMap

2018-11-18 Thread yawkat
According to JCIP, a happens-before order also constitutes a safe publication of the objects involved. Since there is a HB edge between the put and the get, this leads to a safe publication of the object stored in the map (safe publication is another JCIP term). JCIP also mentions CM

Re: Happens before between putting and getting from and to ConcurrentHashMap

2018-11-18 Thread Gil Tene
Well, I was wrong on the internet. (Again). Vladimir is right, the happens-before is transitive. Regardless of the order of execution on either side, every field initialization (final or otherwise) happens-before the put(), and therefor happens-before any subsequent get() on any thread, such

Re: Happens before between putting and getting from and to ConcurrentHashMap

2018-11-18 Thread Jean-Philippe BEMPEL
Hello Vladimir, On Sunday, November 18, 2018, Vladimir Sitnikov wrote: > > > In this case that contract is provided by JLS "17.4.3. Programs and > Program Order" and "17.4.5. Happens-before Order" . > TL;DR: "If x and y are actions of the same thread and x comes before y in > program order, then

Re: Happens before between putting and getting from and to ConcurrentHashMap

2018-11-18 Thread Vladimir Sitnikov
Gil>I'd be happy I wish you all the best. I truly adore the way you explain things. Gil>There is no contract I've found that establishes a happens-before relationship between the initialization of non-final fields in some object construction and the put of that object (or of some object that