All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.simpleframework.util.thread.SchedulerQueue Maven / Gradle / Ivy

Go to download

Simple is a high performance asynchronous HTTP server for Java

There is a newer version: 5.1.6
Show newest version
/*
 * SchedulerQueue.java February 2007
 *
 * Copyright (C) 2007, Niall Gallagher 
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General 
 * Public License along with this library; if not, write to the 
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
 * Boston, MA  02111-1307  USA
 */

package org.simpleframework.util.thread;

import java.util.concurrent.ScheduledThreadPoolExecutor;

/**
 * The SchedulerQueue object is used to schedule tasks 
 * for execution. This queues the task for the requested period of 
 * time before it is executed. It ensures that the delay is adhered 
 * to such that tasks can be timed for execution in an accurate way.
 * 
 * @author Niall Gallagher
 */
class SchedulerQueue extends ScheduledThreadPoolExecutor {
   
   /**
    * Constructor for the SchedulerQueue object. This 
    * will create a scheduler with a fixed number of threads to use
    * before execution. Depending on the types of task that are
    * to be executed this should be increased for accuracy.
    * 
    * @param size this is the number of threads for the scheduler
    */   
   public SchedulerQueue(int size) {
      super(size);
   }
   
   /**
    * This is used to stop the executor by interrupting all running
    * tasks and shutting down the threads within the pool. This will
    * return immediately once it has been stopped, and not further
    * tasks will be accepted by this pool for execution.
    */    
   public void stop() {
      shutdown();
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy