I'd like to effectively "poll" on a JavaFX TableView so that if a job is created in the database by another user the current user would pick it up (let's say every 5 seconds).
I have tried using Timer;
new Timer().schedule(new TimerTask() {
@Override
public void run() {
try {
newI(connection, finalQuery, adminID);
} catch (SQLException e) {
e.printStackTrace();
}
}
}, 0, 5000);
However this gets the following error: Exception in thread "Timer-0" java.lang.IllegalStateException: This operation is permitted on the event thread only; currentThread = Timer-0
which I assume means that it is not supported in JavaFX? How am I able to periodically update the TableView in JavaFX?