Class ConcurrentScheduler
java.lang.Object
org.simpleframework.common.thread.ConcurrentScheduler
The
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.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SchedulerQueue
This is the scheduler queue used to enque tasks to execute. -
Constructor Summary
ConstructorsConstructorDescriptionConcurrentScheduler
(Class type) Constructor for theConcurrentScheduler
object.ConcurrentScheduler
(Class type, int size) Constructor for theConcurrentScheduler
object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
This will execute the task within the executor immediately as it uses a delay duration of zero milliseconds.void
This will execute the task within the executor after the time specified has expired.void
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.
-
Field Details
-
queue
This is the scheduler queue used to enque tasks to execute.
-
-
Constructor Details
-
ConcurrentScheduler
Constructor for theConcurrentScheduler
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.- Parameters:
type
- this is the type of the worker threads
-
ConcurrentScheduler
Constructor for theConcurrentScheduler
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.- Parameters:
type
- this is the type of the worker threadssize
- this is the number of threads for the scheduler
-
-
Method Details
-
execute
This will execute the task within the executor immediately as it uses a delay duration of zero milliseconds. This can be used if the scheduler is to be used as a thread pool. -
execute
This will execute the task within the executor after the time specified has expired. If the time specified is zero then it will be executed immediately. Once the scheduler has been stopped then this method will no longer accept runnable tasks. -
execute
This will execute the task within the executor after the time specified has expired. If the time specified is zero then it will be executed immediately. Once the scheduler has been stopped then this method will no longer accept runnable tasks. -
stop
public void stop()This is used to stop the scheduler 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. -
stop
public void stop(long wait) This is used to stop the scheduler by interrupting all running tasks and shutting down the threads within the pool. This will return once it has been stopped, and no further tasks will be accepted by this pool for execution.- Parameters:
wait
- the number of milliseconds to wait for it to stop
-