|
|
|
|
Re: Concurrent Jobs? [message #435426 is a reply to message #435297] |
Wed, 17 August 2005 23:55 |
Eclipse User |
|
|
|
Originally posted by: kent.generatescape.com
did you solve this?
I am experiencing similiar behavior with jobs, and I can't find any
behaviour that would be cause blocking.
"John Arthorne" <john@eclipsefaq.org> wrote in message
news:ddfp0f$lsb$1@news.eclipse.org...
> Aashish Patil wrote:
>> The problem is that they are not running concurrently. Instead the
>> execution is sequential. I want it to be concurrent.
>
> Jobs run concurrently. If yours are not, then one must be blocking the
> other one by acquiring some kind of lock. Here is an example:
>
> public class JobTest {
> static class TestJob extends Job {
> public TestJob(String name) {
> super(name);
> }
> protected IStatus run(IProgressMonitor monitor) {
> for (int i = 0; i < 5; i++) {
> System.out.println(getName() + ' ' + i);
> try {
> Thread.sleep(100);
> } catch (InterruptedException e) {}
> }
> return Status.OK_STATUS;
> }
> };
> public static void main(String[] args) {
> TestJob a = new TestJob("A");
> TestJob b = new TestJob("B");
> a.schedule();
> b.schedule();
> }
> }
>
> The output when I run this is:
>
> A 0
> B 0
> A 1
> B 1
> A 2
> B 2
> A 3
> B 3
> A 4
> B 4
>
> This shows that the jobs are running concurrently.
> --
|
|
|
|
Powered by
FUDForum. Page generated in 0.05122 seconds