code: public <T> T doInCriticalSection(Task task, List<Interval> intervals, CriticalAction<T> action) throws Exception
    {
      giant.lock();
  
      try {
        return action.perform(isTaskLocksValid(task, intervals));
      }
      finally {
        giant.unlock();
      }
    }
docs: Perform the given action with a guarantee that the locks of the task are not revoked in the middle of action.  This
  method first checks that all locks for the given task and intervals are valid and perform the right action.
  
  The given action should be finished as soon as possible because all other methods in this class are blocked until
  this method is finished.
  
  @param task      task performing a critical action
  @param intervals intervals
  @param action    action to be performed inside of the critical section