Detecting threading problems faster

John Hendrikx john.hendrikx at gmail.com
Wed Aug 7 18:52:32 UTC 2024


Hey Michael,

Thanks, I totally forgotten about that post apparently, perhaps we can 
make this work.

I thought of something else as well. We seem to be assuming that 
checking the Thread is the expensive part, where it in reality is one of 
the cheapest checks that we can do.  We could always check the thread, 
and only do a further investigation if that thread is NOT the FX thread, 
perhaps something like this:

     if (getBean() != null && !Thread.currentThread().equals(FXThread)) {
           // Investigate further... we're either offline (safe) or 
online (not safe)
           if (notSafe()) throw exception;
     }
     // proceed as normal

The above checks are both incredibly cheap.

In the case where we want to do a deeper investigation, we're either 
offline where performance will be a lot less important (graphs can be 
built by other threads), or we're online, which is the case that we want 
to warn users about.  In both cases, a somewhat reduced performance 
won't matter much, while the case when the graph is live and is called 
correctly will be perform almost unimpeded.

--John


On 05/08/2024 17:35, Michael Strauß wrote:
> Hi John,
>
> this seems to be a very similar idea to what I've proposed a year ago:
> https://mail.openjdk.org/pipermail/openjfx-dev/2023-August/041925.html
>
> I think the potential performance impact needs to be carefully considered.


More information about the openjfx-dev mailing list