On Tue, 6 May 2025 18:51:47 GMT, Andy Goryachev <ango...@openjdk.org> wrote:

>> `volatile` is not enough, because the different values are correlated (for 
>> example `foreground`, `background`, and `colorScheme`). All values need to 
>> be updated in a single transaction, as otherwise we could end up reading a 
>> transient combination of values.
>
> I see.  The I suggest we enforce single-threaded nature of it: everything 
> must happen in the FX Application Thread.  I don't think it's a good idea to 
> start synchronizing things in FX now all of a sudden.
> 
> Any code that wants to access FX from a background thread must do so using a 
> combination of `runLater` and a `CountDownLatch`.
> 
> What do you think?

That would be okay, except that `Scene` is allowed to be created on a 
background thread (it's in the class documentation), so we can't completely 
enforce it to be single-threaded. Once a scene is created, a user can also 
request its preferences. This is when we need some way to get the current 
platform preferences on a background thread, as otherwise users would 
potentially see the scene preferences suddenly change once the scene is shown.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1655#discussion_r2076107914

Reply via email to