On Mon, 13 Oct 2025 16:51:54 GMT, Johan Vos <[email protected]> wrote:
>> 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. I know you do - the links were added for sake of others :-) The answer to your question is - I don't know. If one can guarantee that there is only one thread accessing it, we may need to add a comment (though things might change in the future, and no one reads comments elsewhere in the code). And if not, then some form of synchronization is mandatory. I prefer not to think though, and make sure we don't plant booby traps in the code. BTW, what is the cost of volatile? 0.1 ns? ;-) ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/1934#discussion_r2426890844
