Code example for ThreadPoolExecutor

Methods: executegetActiveCountgetQueuegetTaskCount

0
  synchronized void execute(Runnable task) {
    if (executor == null) {
      throw new RuntimeException("AsyncDataService is already shutdown");
    } 
    if (LOG.isDebugEnabled()) {
      LOG.debug("Current active thread number: " + executor.getActiveCount()
          + " queue size:" + executor.getQueue().size()
          + " scheduled task number:" + executor.getTaskCount());
    } 
    executor.execute(task);
  } 
 
  /** 
   * Gracefully shut down the ThreadPool. Will wait for all data tasks to 
   * finish. 
   */ 
  synchronized void shutdown() { 
    if (executor == null) {
      LOG.warn("AsyncDataService has already shut down.");
    } else {