public static ActiveObject createActiveObject() {
   Servant servant = new Servant();
   ActivationQueue queue = new ActivationQueue();
   SchedulerThread scheduler = new SchedulerThread(queue);
   Proxy proxy = new Proxy(scheduler, servant);
   scheduler.start();
   return proxy;
 }
 public static ActiveObject createActiveObject() {
   Servant servant = new Servant();
   ActivationQueue queue = new ActivationQueue();
   SchedulerThread scheduler = new SchedulerThread(queue); // use for execute Request
   Proxy proxy = new Proxy(scheduler, servant); // wrapper future result and request queue
   scheduler.start(); //
   return proxy;
 }
 @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);
 }
 @Stop
 public final void stop() {
   enabled = false;
   if (schedulerThread != null) {
     schedulerThread.interrupt();
   }
 }
 private void initIfNeeded() {
   if (!enabled || schedulerThread != null) {
     return;
   }
   schedulerThread = new SchedulerThread(cacheName);
   schedulerThread.start();
 }
  @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;
  }
 @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();
 }
 public void setSt(SchedulerThread st) {
   this.st = st;
   st.setPause(true);
   st.start();
 }