public class ConcurrentScheduler extends Object implements Scheduler
ConcurrentScheduler
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.Constructor and Description |
---|
ConcurrentScheduler(Class type)
Constructor for the
ConcurrentScheduler object. |
ConcurrentScheduler(Class type,
int size)
Constructor for the
ConcurrentScheduler object. |
Modifier and Type | Method and Description |
---|---|
void |
execute(Runnable task)
This will execute the task within the executor immediately
as it uses a delay duration of zero milliseconds.
|
void |
execute(Runnable task,
long delay)
This will execute the task within the executor after the time
specified has expired.
|
void |
execute(Runnable task,
long delay,
TimeUnit unit)
This will execute the task within the executor after the time
specified has expired.
|
void |
stop()
This is used to stop the scheduler by interrupting all running
tasks and shutting down the threads within the pool.
|
void |
stop(long wait)
This is used to stop the scheduler by interrupting all running
tasks and shutting down the threads within the pool.
|
public ConcurrentScheduler(Class type)
ConcurrentScheduler
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.type
- this is the type of the worker threadspublic ConcurrentScheduler(Class type, int size)
ConcurrentScheduler
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.type
- this is the type of the worker threadssize
- this is the number of threads for the schedulerpublic void execute(Runnable task)
public void execute(Runnable task, long delay)
public void execute(Runnable task, long delay, TimeUnit unit)
public void stop()
public void stop(long wait)
wait
- the number of milliseconds to wait for it to stopCopyright © 2016. All rights reserved.