0 Replies - 8498 Views - Last Post: 20 January 2013 - 11:50 PM Rate Topic: -----

#1 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10397
  • View blog
  • Posts: 38,467
  • Joined: 27-December 08

[Link] JavaFX Series- Threading Issues

Posted 20 January 2013 - 11:50 PM

Quote

Because the call to add a new object came from a thread started by a business class, it can not get directly processed. This would cause the following exception:

Exception in thread "Timer-1" java.lang.IllegalStateException: Not on FX application thread; currentThread = Timer-1

This is the reason why the whole body of the method is wrapped in Platform.runLater(). Quoting from the API doc, this method runs the specified Runnable on the JavaFX Application Thread at some unspecified time in the future. This method, which may be called from any thread, will post the Runnable to an event queue and then return immediately to the caller. The Runnables are executed in the order they are posted.

This method allows for a complete separation of the UI and the business logic. Before reading about this method here, I thought that every call to a JavaFX component has to come directly from the FX application thread. That would have broken my architecture and my separations of concerns.


http://stevenschwenk...ThreadingIssues

Is This A Good Question/Topic? 0
  • +

Page 1 of 1