public class DefaultThreadExecutor extends Object implements ThreadExecutor
Constructor and Description |
---|
DefaultThreadExecutor()
Creates a new task executor.
|
DefaultThreadExecutor(String threadPoolName,
int corePoolSize,
int maximumPoolSize,
int scheduleCorePoolSize)
Creates a new task executor with fixed thread pool size.
|
DefaultThreadExecutor(ThreadPoolExecutor executor,
ScheduledExecutorService scheduledExecutor)
Creates a new task executor.
|
Modifier and Type | Method and Description |
---|---|
<T> ScheduledFuture<T> |
schedule(Callable<T> task,
javax.measure.Measurable<javax.measure.quantity.Duration> delay)
Creates and executes a ScheduledFuture that becomes enabled after the
given delay.
|
ScheduledFuture<?> |
schedule(Runnable task,
javax.measure.Measurable<javax.measure.quantity.Duration> delay)
Creates and executes a ScheduledFuture that becomes enabled after the
given delay.
|
ScheduledFuture<?> |
scheduleAtFixedRate(Runnable task,
Date initialTime,
javax.measure.Measurable<javax.measure.quantity.Duration> period)
For the sake of cancellability but not provide a usable result Creates
and executes a periodic action that becomes enabled first at the given
initial time, and subsequently with the given period; that is
executions will commence at initialTime then initialTime+period, then
initialTime + 2 * period, and so on.
|
ScheduledFuture<?> |
scheduleAtFixedRate(Runnable task,
javax.measure.Measurable<javax.measure.quantity.Duration> initialDelay,
javax.measure.Measurable<javax.measure.quantity.Duration> period)
Creates and executes a periodic action that becomes enabled first after
the given initial delay, and subsequently with the given period; that
is executions will commence after initialDelay then
initialDelay+period, then initialDelay + 2 * period, and so on.
|
ScheduledFuture<?> |
scheduleWithFixedDelay(Runnable task,
javax.measure.Measurable<javax.measure.quantity.Duration> initialDelay,
javax.measure.Measurable<javax.measure.quantity.Duration> delay)
Creates and executes a periodic action that becomes enabled first after
the given initial delay, and subsequently with the given delay between
the termination of one execution and the commencement of the next.
|
void |
shutdown()
Initiates an orderly shutdown in which previously submitted tasks are
executed, but no new tasks will be accepted.
|
<T> Future<T> |
submit(Callable<T> task)
This method is used to decouple execution of task i.e.
|
Future<?> |
submit(Runnable task)
This method is use to decouple execution of task i.e.
|
public DefaultThreadExecutor()
public DefaultThreadExecutor(String threadPoolName, int corePoolSize, int maximumPoolSize, int scheduleCorePoolSize)
threadPoolName
- thread pool namecorePoolSize
- the number of threads to keep in the pool, even if
they are idlemaximumPoolSize
- the maximum number of threads to allow in the
poolscheduleCorePoolSize
- the number of schedule threads to keep in
the pool, even if they are idlepublic DefaultThreadExecutor(ThreadPoolExecutor executor, ScheduledExecutorService scheduledExecutor)
executor
- the executor to submit non-scheduled tasksscheduledExecutor
- the executor to submit scheduled taskspublic Future<?> submit(Runnable task)
RunnableExecutor
submit
in interface RunnableExecutor
task
- task to be executedpublic <T> Future<T> submit(Callable<T> task)
CallableExecutor
submit
in interface CallableExecutor
T
- type of the execution resulttask
- task to be executedpublic <T> ScheduledFuture<T> schedule(Callable<T> task, javax.measure.Measurable<javax.measure.quantity.Duration> delay)
ThreadExecutor
schedule
in interface ThreadExecutor
T
- the type of the execution resulttask
- the task to be executeddelay
- the time from now to delay executionpublic ScheduledFuture<?> schedule(Runnable task, javax.measure.Measurable<javax.measure.quantity.Duration> delay)
ThreadExecutor
schedule
in interface ThreadExecutor
task
- the runnable task to be executeddelay
- the time from now to delay executionpublic ScheduledFuture<?> scheduleAtFixedRate(Runnable task, javax.measure.Measurable<javax.measure.quantity.Duration> initialDelay, javax.measure.Measurable<javax.measure.quantity.Duration> period)
ThreadExecutor
scheduleAtFixedRate
in interface ThreadExecutor
task
- the task to be executedinitialDelay
- the time to delay first executionperiod
- the period between successive executionspublic ScheduledFuture<?> scheduleAtFixedRate(Runnable task, Date initialTime, javax.measure.Measurable<javax.measure.quantity.Duration> period) throws IllegalArgumentException
ThreadExecutor
scheduleAtFixedRate
in interface ThreadExecutor
task
- the task to be executedinitialTime
- the time of the first executionperiod
- the period between successive executionsIllegalArgumentException
- if initialTime is in the pastpublic ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, javax.measure.Measurable<javax.measure.quantity.Duration> initialDelay, javax.measure.Measurable<javax.measure.quantity.Duration> delay)
ThreadExecutor
scheduleWithFixedDelay
in interface ThreadExecutor
task
- the task to be executedinitialDelay
- the time to delay first execution.delay
- the delay between the termination of one execution and the
commencement of the nextpublic void shutdown()
Copyright © 2015. All Rights Reserved.