I have this existing Timer function:
final Timer waveTimer = new Timer() {
@Override
public void run() {
double value = r.getByte(); // takes quite long to finish
wave.renderWaveOnFly(value);
}};
waveTimer.scheduleRepeating(50);
However it works, the UI is "blocked" and that user can't click and do anything in the UI until the timer finishes when part of the UI calls waveTimer.cancel()
which I created another Timer that cancels this timer after 10 seconds, so the UI is not usable until then.
Is there a way to implement a non-blocking timer such that it would pause for some time, perhaps just to make sure that the UI is not blocked and the user can still do something in the UI.
I mean, still have the feel that the UI is still responsive.
I am not sure about the figure, but say like every 100 millisec it stops and then give way for the UI and resume 100 millisec after the pause or something like this. I am thinking what approach to deal with.