Javafx embedded in swing multithreaded toolkit issue

steve.x.northover at oracle.com steve.x.northover at oracle.com
Tue Mar 20 19:48:53 PDT 2012


Believe me, you don't ever want to wait when talking between the 
threads.  You will get deadlock for sure.

Unfortunately, there is no way to make AWT/Swing and JFX share a single 
user-interface thread.  The architecture of AWT/Swing will not allow 
it.  Essentially, there is a "hidden GUI thread" (is it still hidden 
these days?) in AWT that pumps events.  This thread must never wait or 
AWT/Swing will deadlock.

Steve

On 20/03/2012 10:17 PM, Pedro Duque Vieira wrote:
> Hi,
>
> I've been working for a while on a swing app that has a javafx scene
> embedded on it.
>
> So in this scenario we have two UI threads, one for the swing part and one
> for the javafx scene (the application thread).
> This situation creates a multithreaded ui toolkit which is basically a
> nightmare for development.
>
> I don't know if this is possible but it I think it would be best to merge
> the swing and the javafx application thread into one when on this scenario.
>
> One other possible solution that comes to my mind  and also a much simpler
> and quicker one is to add a Platform.invokeAndWait(like what exists on
> swing) alongside the Platform.runLater to the javafx API.
> And each time I want to invoke something on the javafx App thread from the
> swing ui thread I call invokeAndWait instead of runLater. So effectively
> the two UI threads become only one, because they are not running
> concurrently but sequentially instead.
>


More information about the openjfx-dev mailing list