@Override
  protected void serviceStart() throws UnknownHostException {
    String localHostName = InetAddress.getLocalHost().getHostName();
    LOG.debug("Local hostname is: {}", localHostName);
    for (String hostName : victimsHostName) {
      if (hostName.equalsIgnoreCase(localHostName)) {
        LOG.debug("Starting load generator process on: {}", localHostName);
        threads = new Thread[Runtime.getRuntime().availableProcessors()];
        Random random = new Random();
        for (int i = 0; i < threads.length; i++) {
          threads[i] = new Thread(new Runnable() {
            @Override
            public void run() {
              while (!Thread.interrupted()) {
                if (random.nextFloat() <= threshold) {
                  // Keep it busy
                  long startTime = System.currentTimeMillis();
                  while (System.currentTimeMillis() - startTime < interval) {
                    // active loop, do nothing, just check interrupt status
                    if (Thread.currentThread().isInterrupted()) {
                      break;
                    }
                  }
                } else {
                  // Keep it idle
                  try {
                    Thread.sleep(interval);
                  } catch (InterruptedException e) {
                    // Set the interrupt flag so we will stop the thread
                    Thread.currentThread().interrupt();
                  }
                }
              }
            }
          });
          threads[i].start();
        }
      }
    }
  }
Extra load generator service for LLAP.
llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/LlapLoadGeneratorService.java