On Mon, 13 Oct 2025 16:32:48 GMT, Kevin Rushforth <[email protected]> wrote:

>> generally speaking, when two threads modify a single boolean variable, there 
>> might be scenarios, depending on the exact hardware, when the other thread 
>> does not see the modified value right away.
>> 
>> some of the comments in 
>> 
>> https://stackoverflow.com/questions/65037547/the-volatile-keyword-and-cpu-cache-coherence-protocol
>> https://stackoverflow.com/questions/106591/what-is-the-volatile-keyword-useful-for
>> 
>> might explain it better.
>
> Can this variable be accessed by two threads where one of them doesn't 
> synchronize some other way? If so, then Andy has a point.

I'm aware of the purpose of volatile :)
However, I'm also aware of the cost of volatile, hence I prefer not to do it 
unless I know there is a possible scenario where it is needed.
That is why I'm asking the same question as the one asked by Kevin.

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1934#discussion_r2426851714

Reply via email to