@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();
                  }
                }
              }
            }
Extra load generator service for LLAP.
llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/LlapLoadGeneratorService.java