Class SimpleTimer
- java.lang.Object
-
- org.apache.accumulo.server.util.time.SimpleTimer
-
public class SimpleTimer extends Object
Generic singleton timer. Don't use this if you are going to do anything that will take very long. Please use it to reduce the number of threads dedicated to simple events.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SimpleTimer
getInstance(int threadPoolSize)
Gets the timer instance.static SimpleTimer
getInstance(AccumuloConfiguration conf)
Gets the timer instance.ScheduledFuture<?>
schedule(Runnable task, long delay)
Schedules a task to run in the future.ScheduledFuture<?>
schedule(Runnable task, long delay, long period)
Schedules a task to run in the future with a fixed delay between repeated executions.
-
-
-
Method Detail
-
getInstance
public static SimpleTimer getInstance(int threadPoolSize)
Gets the timer instance. If an instance has already been created, it will have the number of threads supplied when it was constructed, and the size provided here is ignored.- Parameters:
threadPoolSize
- number of threads
-
getInstance
public static SimpleTimer getInstance(AccumuloConfiguration conf)
Gets the timer instance. If an instance has already been created, it will have the number of threads supplied when it was constructed, and the size provided by the configuration here is ignored. If a null configuration is supplied, the number of threads defaults to 1.- Parameters:
conf
- configuration from which to get the number of threads- See Also:
Property.GENERAL_SIMPLETIMER_THREADPOOL_SIZE
-
schedule
public ScheduledFuture<?> schedule(Runnable task, long delay)
Schedules a task to run in the future.- Parameters:
task
- task to rundelay
- number of milliseconds to wait before execution- Returns:
- future for scheduled task
-
schedule
public ScheduledFuture<?> schedule(Runnable task, long delay, long period)
Schedules a task to run in the future with a fixed delay between repeated executions.- Parameters:
task
- task to rundelay
- number of milliseconds to wait before first executionperiod
- number of milliseconds to wait between executions- Returns:
- future for scheduled task
-
-