Platform#runLater Question

Anthony Petrov anthony.petrov at oracle.com
Tue Apr 2 01:18:11 PDT 2013


Platform#runLater is not a general purpose mechanism to execute deferred 
tasks. Its purpose is to schedule execution of runnables on the event 
thread in order to perform GUI-related operations. As Richard says, the 
event thread is a native GUI thread. There's only one such thread per 
application, hence the design of this machinery.

Note that running code that is unrelated to GUI on the event thread may 
only make your application UI more sluggish and jerky, or even appearing 
frozen sometimes.

If you need to execute general-purpose tasks asynchronously, you have to 
create an executor service instance (such as a ForkJoinPool) yourself 
and submit your runnables there.

--
best regards,
Anthony

On 4/1/2013 23:05, Mark Fortner wrote:
> In the past, I've found the *Platform#runLater* method to be a useful way
> to run tasks. However, I've noticed that the code that runs my thread is
> not really configurable or accessible.  For example, it would be nice to be
> able to specify and configure a top-level *ThreadPoolExecutor* to handle my
> tasks.  Or be able to switch out *Executor* implementations.
> 
> I was wondering if there was some reason for implementing runLater this
> way, or if there are any plans to change it in the future?
> 
> 
> Cheers,
> 
> Mark


More information about the openjfx-dev mailing list