?
=?iso-8859-1?q?J=FCrgen_Gerstacker?=
Hello!
I have a question about the need of a repainting thread.
I have an application with a timer, that is being fired each
millisecond:
Timer timer;
SmfpTimerTask timerTask;
timerTask=new SmfpTimerTask();
timer.schedule(timerTask,0,1);
class SmfpTimerTask extends TimerTask {
public void run() {
calculations...
if (condition) textfield.setText("...");
}
...
}
The code inside the run() function of the timerTask must be very very
quick (<< 1ms).
TimerCallbacks, for window-altering functions may need some time to
execute (>1 ms).
I can imagine, that textfield.setText() could take longer to execute
depending on certain cirumstances.
In Windows C++ I would write PostMessage(hwnd,WM_SETTEXT,...) to alter
a textfield, because PostMessage returns before finishing the task.
What is the Java-Way to do this? Is the code above safe?
Or is it better to let the textfield.setText() and other repainting
stuff be done in an extra thread?
Thank you, Juergen
I have a question about the need of a repainting thread.
I have an application with a timer, that is being fired each
millisecond:
Timer timer;
SmfpTimerTask timerTask;
timerTask=new SmfpTimerTask();
timer.schedule(timerTask,0,1);
class SmfpTimerTask extends TimerTask {
public void run() {
calculations...
if (condition) textfield.setText("...");
}
...
}
The code inside the run() function of the timerTask must be very very
quick (<< 1ms).
PostMessage() and PostMessageThread() functions are allowed within inFrom my Windows C++ programming experience I know, that only
TimerCallbacks, for window-altering functions may need some time to
execute (>1 ms).
I can imagine, that textfield.setText() could take longer to execute
depending on certain cirumstances.
In Windows C++ I would write PostMessage(hwnd,WM_SETTEXT,...) to alter
a textfield, because PostMessage returns before finishing the task.
What is the Java-Way to do this? Is the code above safe?
Or is it better to let the textfield.setText() and other repainting
stuff be done in an extra thread?
Thank you, Juergen