Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » How to sequence timerexecs in display swt(How to sequence timerexecs in display swt)
How to sequence timerexecs in display swt [message #1078175] Fri, 02 August 2013 16:27
Musical Developer is currently offline Musical DeveloperFriend
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
like ordering them according to time of submission or some other criteria?

Any ideas/suggestions?

[Updated on: Fri, 02 August 2013 17:10]

Report message to a moderator

Previous Topic:java.lang.NullPointerException
Next Topic:Forever Indexing
Goto Forum:
  


Current Time: Sun Mar 07 05:59:26 GMT 2021

Powered by FUDForum. Page generated in 0.02646 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top