Reputation: 1105
I'm working on a SWT application for creating a automatic testing tool. I need to implement multithreading and I've heard Eclipse jobs Api can help me with it. I couldn't find it with my eclipse bundle. Can anyone point me to the location where I could download it or if you have any other solution, please do tell me. Thanks in advance.
Upvotes: 1
Views: 296
Reputation: 1105
Thanks to Greg, I've realized jobs cannot be used for SWT application. As an alternative, I've used
Thread.start() => Creates a background thread
Display.getDefault().asyncExec(new Runnable() {}) => A background thread cannot update UI,so this is used
Ref:- Run thread in background in java How to update JFrame Label within a Thread? - Java http://www.javalobby.org/java/forums/t43753.html
I hope this would help someone who are looking for multithreading solutions in SWT.
Upvotes: 1
Reputation: 111142
The Eclipse job classes are in org.eclipse.core.runtime.jobs
. The main class to submit a job is Job
.
Usually used by doing:
Job job = new MyJob();
job.schedule();
where MyJob
is a class which extends Job
. You implement the run
method to do your work.
See http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fcore%2Fruntime%2Fjobs%2Fpackage-summary.html for a description of the various classes
Also see http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fcore%2Fruntime%2Fjobs%2Fclass-use%2FJob.html for a longer overview
Upvotes: 1