On Fri, 20 Jun 2025 20:28:43 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:
>>> I mean that there's a _happens before_ relation each time the synchronized >>> block is reach whereas with volatile, the _happens before_ relation is >>> guaranteed only when the value of the variable changes. >> >> I do not think that this is true "guaranteed only when the value of the >> variable changes". >>>A write to a volatile field >>>([§8.3.1.4](https://docs.oracle.com/javase/specs/jls/se14/html/jls-8.html#jls-8.3.1.4)) >>> happens-before every subsequent read of that field. > > Exactly! A *write* to a volatile field. > > Yet entering and leaving a synchronized block gives a happens-before relation > *each time*. What I mean is two threads that called `GraphicsDevice.getFullScreenWindow` still established a *happens-before* relation for each call, which will be gone with the volatile modifier. It may be fine… or may be not… this is why I'm asking. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25818#discussion_r2159631528