private void addLockToJobsNeedingLock(String lock,Job job){
  ArrayList<Job> jobs=lockToJobsNeedingLock.get(lock);
  if (jobs == null) {
    jobs=new ArrayList<>();
    lockToJobsNeedingLock.put(lock,jobs);
  }
  jobs.add(job);
}

private void addLockToJobsNeedingLock ( String lock , Job job ) { ArrayList < Job > jobs = lockToJobsNeedingLock . get ( lock ) ; if ( jobs == null ) { jobs = new ArrayList < > ( ) ; lockToJobsNeedingLock . put ( lock , jobs ) ; } jobs . add ( job ) ; }
to keep track of what jobs need what lock , update the internal data structures to indicate that the supplied job needs the specified lock before running .
