@ManagedAttribute(description = "The approximate percentage of active threads in the thread pool")
  @Metric(
      displayName = "Percentage of Active Threads",
      units = Units.PERCENTAGE,
      displayType = DisplayType.SUMMARY)
  public double getUsagePercentage() {
    SchedulerThread current = schedulerThread;
    if (current == null) {
      return 0D;
    }

    int max = current.getExecutorService().getMaximumPoolSize();
    int actual = current.getExecutorService().getActiveCount();
    double percentage = actual * 100.0 / max;
    return percentage > 100 ? 100.0 : percentage;
  }
 @ManagedOperation(description = "Set the idle time of a thread in the thread pool (milliseconds)")
 @Operation(displayName = "Set Keep Alive Time of Idle Threads")
 public void setKeepAliveTime(long milliseconds) {
   SchedulerThread current = schedulerThread;
   if (!enabled || current == null) {
     return;
   }
   current.getExecutorService().setKeepAliveTime(milliseconds, TimeUnit.MILLISECONDS);
 }
 @ManagedOperation(description = "Set the maximum number of threads in the thread pool")
 @Operation(displayName = "Set Maximum Number Of Threads")
 public void setMaximumPoolSize(int size) {
   SchedulerThread current = schedulerThread;
   if (!enabled || current == null) {
     return;
   }
   current.getExecutorService().setMaximumPoolSize(size);
 }
 @ManagedAttribute(
     description = "The keep alive time of an idle thread in the thread pool (milliseconds)")
 @Metric(
     displayName = "Keep Alive Time of a Idle Thread",
     units = Units.MILLISECONDS,
     displayType = DisplayType.DETAIL)
 public long getKeepAliveTime() {
   SchedulerThread current = schedulerThread;
   return current == null
       ? 0
       : current.getExecutorService().getKeepAliveTime(TimeUnit.MILLISECONDS);
 }
 @ManagedAttribute(description = "The maximum number of threads in the thread pool")
 @Metric(displayName = "Maximum Number of Threads", displayType = DisplayType.DETAIL)
 public int getMaximumPoolSize() {
   SchedulerThread current = schedulerThread;
   return current == null ? 0 : current.getExecutorService().getMaximumPoolSize();
 }