JavaFX Threading

steve.x.northover at steve.x.northover at
Wed Mar 6 09:49:02 PST 2013

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:

If you are interested, add yourself, please add yourself to it and 
comment either there or on this list,


More information about the openjfx-dev mailing list