On Fri, 31 Jan 2025 19:36:02 GMT, Kevin Rushforth <k...@openjdk.org> wrote:

>> Created a test that validates various Nodes can be initialized in a 
>> background thread.
>
> tests/system/src/test/java/test/robot/javafx/scene/NodeInitializationBackgroundThreadTest.java
>  line 779:
> 
>> 777: 
>> 778:     private static boolean nextBoolean() {
>> 779:         return new Random().nextBoolean();
> 
> It is a best practice when using Random to share a single instance and not 
> allocate a new one each time. It is more performant and more random.

while true, the shared instance will add synchronization and this is something 
I would like to avoid.  The degree of randomness is not that important in this 
case.

the only thing that we lose is reproducibility, but in the case of a headful 
test it's probably impossible anyway, due to many other factors.

In any case, I think the main purpose of this test is a sort of sanity check of 
the requirement, not an exhaustive test of all the properties and all the 
methods that the application can call from a background thread - at least that 
what I thought at the time of writing.  We can always add more stress to it.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1690#discussion_r1937935407

Reply via email to