private void removeLockToJobsNeedingLock(String lock,Job job,boolean shouldBeAtHead){
  ArrayList<Job> jobs=lockToJobsNeedingLock.get(lock);
  if (shouldBeAtHead && jobs.get(0) != job) {
    throw new RuntimeException("Tried to remove " + job + " but it "+ "wasn't at the head of the list for lock "+ lock+ "! List is: "+ jobs);
  }
  boolean removed=jobs.remove(job);
  if (!removed) {
    throw new RuntimeException("Didn't remove job " + job + " from list "+ jobs);
  }
}

private void removeLockToJobsNeedingLock ( String lock , Job job , boolean shouldBeAtHead ) { ArrayList < Job > jobs = lockToJobsNeedingLock . get ( lock ) ; if ( shouldBeAtHead && jobs . get ( 0 ) != job ) { throw new RuntimeException ( "Tried to remove " + job + " but it " + "wasn't at the head of the list for lock " + lock + "! List is: " + jobs ) ; } boolean removed = jobs . remove ( job ) ; if ( ! removed ) { throw new RuntimeException ( "Didn't remove job " + job + " from list " + jobs ) ; } }
mark the lock as not being needed by the specified job in the internal data structures .
