JavaFX Threading

Philipp Dörfler phdoerfler at gmail.com
Thu Mar 7 02:35:21 PST 2013


+1 for the change

~ philipp

Am 07.03.2013 um 02:03 schrieb Kevin Rushforth <kevin.rushforth at oracle.com>:

> Does anyone think we shouldn't make this change? While it is a behavioral change, I doubt it will cause problems for applications. On the contrary, naive applications will be less likely to run into problems after this change. Sophisticated applications can still do background loading in the init() method for long-running initialization.
> 
> One slight correction to what Steve wrote:
> 
>> What about application construction?
>> 
>> Today, this is unspecified ...
> 
> Actually, this is specified today. The javadoc for the Application class says this:
> 
> * The Application constructor and {@code init} method are called on
> * the launcher thread, not on the JavaFX Application Thread.
> * This means that an application must not construct a {@link Scene}
> * or a {@link Stage} in either the constructor or in the {@code init}
> * method.
> 
> So we will need to change the docs as part of this JIRA.
> 
> -- Kevin
> 
> 
> steve.x.northover at oracle.com wrote:
>> Hi all,
>> 
>> One of the great things about JavaFX is that it has a consistent threading model that maps well on to the underlying platforms.  There is a single distinguished GUI-thread that is also the GUI-thread for the window system.  This makes JavaFX GUI behavior consistent and deterministic.  In general, running code in the GUI thread is a good thing for these reasons and others, provided that the code is not long running.  In the case of long running code, JavaFX objects may be created in background threads as long are they are not attached to the scene graph.
>> 
>> JavaFX applications have a life cycle that includes, construction, init(), start() and stop().  The start() method is the most important and runs in the GUI-thread.  The init() method is guaranteed to run in a background thread and is the place where long running creation code can reside.  The start() method will always run after init() has completed.  With a preloader, the start() of the preloader runs at the same time as the init() of the application.  The stop() method is also guaranteed to run in the GUI-thread.
>> 
>> What about application construction?
>> 
>> Today, this is unspecified and happens in a background thread.  We are considering moving this to the GUI-thread.  Here is the JIRA that is tracking this work:
>> 
>>    http://javafx-jira.kenai.com/browse/RT-28754
>> 
>> If you are interested, add yourself, please add yourself to it and comment either there or on this list,
>> 
>> Thanks!
>> Steve
>> 
>> 



More information about the openjfx-dev mailing list