public List<JobItemBean> listJobs(String user, boolean showall, String jobId,
                                    int numRecords, boolean showDetails)
    throws NotAuthorizedException, BadParam, IOException, InterruptedException {

    UserGroupInformation ugi = null;
    WebHCatJTShim tracker = null;
    ArrayList<String> ids = new ArrayList<String>();

    try {
      ugi = UgiFactory.getUgi(user);
      tracker = ShimLoader.getHadoopShims().getWebHCatShim(appConf, ugi);

      JobStatus[] jobs = tracker.getAllJobs();

      if (jobs != null) {
        for (JobStatus job : jobs) {
          String id = job.getJobID().toString();
          if (showall || user.equals(job.getUsername()))
            ids.add(id);
        }
      }
    } catch (IllegalStateException e) {
      throw new BadParam(e.getMessage());
    } finally {
      if (tracker != null)
        tracker.close();
      if (ugi != null)
        FileSystem.closeAllForUGI(ugi);
    }

    return getJobStatus(ids, user, showall, jobId, numRecords, showDetails);
  }
Current thread id used to set in execution threads.
hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/ListDelegator.java