|Re: Job not guaranteed to be scheduled ? eg @startup [message #629151 is a reply to message #628832]
||Mon, 27 September 2010 11:20
| Guy Rooms
Registered: May 2010
Thx for your clarification.
I had a closer look into spec, and indeed, as you mentioned, jobstate is not something to rely on.
What I wanted to do is in fact create a job, schedule it and wait for its completion before proceeding: the Job's run method is querying/building up some critical data, clients should only access it after the query job has completed.
So, I hoped to achieve this by
 Job job = new MyJob();
but noticed job.join even returned before the job actually started.
That's why I started playing with the getState method (ref the inital code excerpt)
Now, reading the spec again, also the join does not guarantee to return only after job has actually run.
So, what's the best thing to do then ?
- register listener +
- block (sleep) code path untill I get informed about RUNNING + NONE state sequence ?
I also tried this yet ended up in waiting for a job that never got scheduled / started.
I guess that blocking the one (..) calling thread(s) did had the side effect the job never got scheduled. Is that possible ?
Maybe I should leave Job as a solution for my particular problem and consider something else: I'm currently using a plain Runnable which seems to do "the job", yet, it would be nicer to show some progress. That's what a typical eclipse user would expect..
Any suggestion is still most welcome.
Powered by FUDForum
. Page generated in 0.02573 seconds