public boolean cancelJob(long id,boolean isPersistent){
  JobHolder holder;
synchronized (getNextJobLock) {
    if (jobConsumerExecutor.isRunning(id,isPersistent))     return false;
    if (isPersistent) {
synchronized (persistentJobQueue) {
        holder=persistentJobQueue.findJobById(id);
        if (holder == null)         return false;
        persistentJobQueue.remove(holder);
      }
    }
 else {
synchronized (nonPersistentJobQueue) {
        holder=nonPersistentJobQueue.findJobById(id);
        if (holder == null)         return false;
        nonPersistentJobQueue.remove(holder);
      }
    }
  }
  BaseJob baseJob=holder.getBaseJob();
  if (dependencyInjector != null) {
    dependencyInjector.inject(baseJob);
  }
  baseJob.onCancel();
  return true;
}

public boolean cancelJob ( long id , boolean isPersistent ) { JobHolder holder ; synchronized ( getNextJobLock ) { if ( jobConsumerExecutor . isRunning ( id , isPersistent ) ) return false ; if ( isPersistent ) { synchronized ( persistentJobQueue ) { holder = persistentJobQueue . findJobById ( id ) ; if ( holder == null ) return false ; persistentJobQueue . remove ( holder ) ; } } else { synchronized ( nonPersistentJobQueue ) { holder = nonPersistentJobQueue . findJobById ( id ) ; if ( holder == null ) return false ; nonPersistentJobQueue . remove ( holder ) ; } } } BaseJob baseJob = holder . getBaseJob ( ) ; if ( dependencyInjector != null ) { dependencyInjector . inject ( baseJob ) ; } baseJob . onCancel ( ) ; return true ; }
cancels job which is waiting to be run .
