public synchronized Task<?> getRunnable(int maxthreads) throws HiveException {
    checkShutdown();
    if (runnable.peek() != null && running.size() < maxthreads) {
      return runnable.remove();
    }
    return null;
  }
Handles the queue of tasks that should be executed by the driver.
ql/src/java/org/apache/hadoop/hive/ql/TaskQueue.java