java - Why is my Thread making my JavaFX Application lag? -


I am trying to create a JavaFX application that uses this code in this controller class Tracks:

  New thread (New Runnabel) {@ Override Public Wide Run} {while (main.running) {Platform.runLater (new Runnabel) {@Override public void run (Try {label.setText (MouseInfo.getPointerInfo (). GetLocation (). ToString ()); Thread.sleep (1000);} Catch (Interrupted Expression E) {e.printStackTrace ();}}})} }}} ).Start();  

But it couses to the end of the big time for my application. How should I fix this problem?

Thank you I decided to:

  New thread (New Runnabal) {@Override Public run zero () {while (main run) {Platform.RunLater (new Runnabel) {@ Override Public Wide Run () {label.setText (MouseInfo.getPointerInfo (). GetLocation (.) ToString ());}}); Try {thread.sleep (200));} grip (interrupted e) e.printStackTrace ();}}}}) Start ();  

What are you doing Javafx application thread Thread.sleep (1000) ; & lt; -wait

Any long-term action that you had taken out of JFX-AT And only update your AI component on it.

  New thread (-) -> {while (main.running) {Platform.runLater ((-) -> {// updateui component / it is being updated on FXAT Is}}; Thread.sleep (time) // Do not wait JFXAT like this}}).) Start ();  

// Not sure if formatted and crisp is correctly braces. You hope that you hope. Make sure that you know which thread you wait for. Otherwise, you will not be able to get an event from JFX paused. / P>


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -