Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Updating the GUI from a background Thread: Platform.Runlater() Vs Tasks

990672Feb 12 2013 — edited Feb 12 2013
Hi Everyone,

Hereby I would like to ask if anyone can enlighten me on the best practice for concurency with JAVAFX2. More precisely, if one has to update a Gui from a background Thread what should be the appropriate approach.

I further explain my though:

I have window with a text box in it and i receive some message on my network on the background, hence i want to update the scrolling textbox of my window with the incoming message. In that scenario what is the best appraoch.

1- Shall i implement my my message receiver as thread in which i would then use a platform.RunLater() ?

2- Or shall i use a Task ? In that case, which public property of the task shall take the message that i receive ? Are property of the task only those already defined, or any public property defined in subclass can be used to be binded in the graphical thread ?


In general i would like to understand, what is the logic behind each method ?

My understanding here, is that task property are only meant to update the gui with respect to the status of the task. However updating the Gui about information of change that have occured on the data model, requires Platform.RunLater to be used.

Edited by: 987669 on Feb 12, 2013 12:12 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 12 2013
Added on Feb 12 2013
2 comments
473 views