How to sequentialize timerexecs in SWT Display [message #1078190] |
Fri, 02 August 2013 16:52 |
Musical Developer Messages: 4 Registered: March 2012 |
Junior Member |
|
|
All,
Facing an interesting situation...
timerexec(long delay, Runnable r) in Display suggests that the r will be run *after* delay milliseconds.
I tried a quick piece of code:
int i = 0;
while( i <= 10){
mine mn = new mine(i);
Display.getDefault().timerExec(500, mn);
i++;
}
i++;
mine last = new mine(i);
Display.getDefault().timerExec(500, last);
class mine implements Runnable{
int j = 0;
public mine(int i){
j = i;
}
public void run() {
System.out.println( " mine: " + this + " value: " + j);
}
}
--
This prints out:
value : 12
value : 10
value : 9
value : 8
value : 7
value : 6
value : 5
value : 4
value : 3
value : 2
value : 1
value : 0
--
Questions:
1. I expected the sysouts to be printed in reverse?
2. In my actual program, I do not have control on a set of events which are timerexec'ed at 500 sequentially. (in some other part of program, cannot change code)
I would like to schedule a timerexec at the end of this set...so that I know
for sure that all previous timerexecs have already been executed!
3. Does display timerexec guarantee order amongst "ready runnables" in its timerList
Any help would be appreciated!
[Updated on: Fri, 02 August 2013 17:00] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03048 seconds