RFR: 8347392: Thread-unsafe implementation of c.s.j.scene.control.skin.Utils

Andy Goryachev angorya at openjdk.org
Fri Feb 7 15:59:16 UTC 2025


On Fri, 7 Feb 2025 07:58:47 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

> What's the rationale for using a borrow pattern here, instead of simply synchronizing access to the object in question?

A very good question!

This pattern seemed to be the most applicable here: the solution needs to be both thread-safe and reentrant, with the expectation that in most cases the simple scenario happens where the static instance is used.

We actually use that pattern using synchronization, see `GlyphLayout::getInstance()` for example.  I think the use of AtomicBoolean is far better, so I took the same approach in #1667 .

Is there a specific scenario that would not work or cause issues?

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

PR Comment: https://git.openjdk.org/jfx/pull/1691#issuecomment-2643323226


More information about the openjfx-dev mailing list