3 Replies Latest reply on Apr 18, 2008 4:09 AM by s s

    about implementation of JobExecutorThread

    s s Newbie

      Hi gurus:
      when I read code in JobExecutorThread.I got confused about the following code snip

       Collection acquiredJobs = acquireJobs();
       
       if (! acquiredJobs.isEmpty()) {
       Iterator iter = acquiredJobs.iterator();
       while (iter.hasNext() && isActive) {
       Job job = (Job) iter.next();
       executeJob(job);
       }
      
       } else { // no jobs acquired
       if (isActive) {
       long waitPeriod = getWaitPeriod();
       if (waitPeriod>0) {
       synchronized(jobExecutor) {
       jobExecutor.wait(waitPeriod);
       }
       }
       }
       }
      

      acquiredJobs are retrieved by "
      select job
      from org.jbpm.job.Job as job
      where ( (job.lockOwner is null) or (job.lockOwner = :lockOwner) )
      and job.retries > 0
      and job.dueDate <= :now
      and job.isSuspended != true
      order by job.dueDate asc
      "

      so I dout that : is the job retrieved really is time to be executed? It's only the latest job ,not anything else.

      Can you guys explains a little for me? thanks a lot