Skip to content
Snippets Groups Projects
Commit 3c49ddb0 authored by LABOUREL Arnaud's avatar LABOUREL Arnaud
Browse files

changed sleepy runnable with a scheduler

parent e8ca8aa1
Branches
No related tags found
No related merge requests found
...@@ -6,6 +6,9 @@ import javafx.scene.layout.HBox; ...@@ -6,6 +6,9 @@ import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.stage.Stage; import javafx.stage.Stage;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import static java.lang.Thread.sleep; import static java.lang.Thread.sleep;
...@@ -31,21 +34,15 @@ public class App extends Application { ...@@ -31,21 +34,15 @@ public class App extends Application {
primaryStage.setScene(new Scene(root)); primaryStage.setScene(new Scene(root));
primaryStage.show(); primaryStage.show();
grid.repaint(); grid.repaint();
new Thread(new Runnable() {
ScheduledThreadPoolExecutor threadPoolExecutor = new ScheduledThreadPoolExecutor(1);
threadPoolExecutor.scheduleWithFixedDelay(new Runnable() {
@Override @Override
public void run() { public void run() {
while(true){
try {
sleep(50);
grid.model.activation(); grid.model.activation();
grid.repaint(); grid.repaint();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} }
}).start(); }, 0, 50 , TimeUnit.MILLISECONDS);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment