[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [p2-dev] Executing a P2 traverse query

Am 15.12.2010 18:33, schrieb David Orme:
> Why?  Nobody on the team could come up with an argument that we needed
> anything more complicated than a standard Java
> Thread.currentThread.sleep(bunchOTime) to schedule a recurring thing to
> happen at some time in the future.

Personally, I prefer having more explicit API and usually use a
self-scheduling job for this. This has the benefit of very clean API.

Job#schedule()
Job#cancel()

If the real Job isn't capable of self-scheduling you can wrap it like this:
Job realJob = ...;
Job schedulingJob = new Job("blah") {
  protected IStatus run(...) {
    // start real job
    realJob.schedule();

    // optionally wait for Job to finish
    realJob.join();

    // reschedule
    long bunchOTime= calculateSleepTime();
    schedule(bunchOTime);
    return Status.OK_STATUS;
  }
}.schedule();


-Gunnar

-- 
Gunnar Wagenknecht
gunnar@xxxxxxxxxxxxxxx
http://wagenknecht.org/