On Fri, 2018-11-09 at 15:36 -0700, Gary Gregory wrote: > On Fri, Nov 9, 2018 at 3:33 PM Oleg Kalnichevski <[email protected]>
... > > > Yes, it is. What would be the point if every single method > > synchronizes > > on exchangeState instance? > > > > > > https://github.com/apache/httpcomponents-core/blob/master/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java#L275 > > > OK, I can buy that all of the synchronized blocks are correct and > schedule > thread access to those ivars. > But what about the absence of volatile causing threads to miss > updates to > fields from other threads? > Java runtime guarantees the state of variables inside synchronized block to be consistent for all threads of execution. The reason for making variables volatile is to avoid having to use expensive synchronization. Oleg > Gary > > > > > > > > Oleg > > > > > > ----------------------------------------------------------------- > > ---- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
