public class TimedExecutorService
extends java.util.concurrent.ThreadPoolExecutor
| Modifier and Type | Class and Description |
|---|---|
static class |
TimedExecutorService.Builder
Builder class for setting up the timed executor service
|
java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy| Modifier and Type | Method and Description |
|---|---|
long |
getDefaultRunDuration()
Gets the default run duration, in milliseconds, that will be set for tasks with no duration specified.
|
protected <T> java.util.concurrent.RunnableFuture<T> |
newTaskFor(java.util.concurrent.Callable<T> callable) |
protected <T> java.util.concurrent.RunnableFuture<T> |
newTaskFor(java.lang.Runnable runnable,
T result) |
void |
setDefaultRunDuration(long duration)
Sets the default run duration, in milliseconds, that will be set for tasks with no duration specified.
|
void |
shutdown() |
java.util.List<java.lang.Runnable> |
shutdownNow() |
<T> java.util.concurrent.Future<T> |
submitTaskWithDuration(java.util.concurrent.Callable<T> task,
long duration)
Runs a task, cancelling it after the specified duration has passed from the time it started running.
|
java.util.concurrent.Future<java.lang.Boolean> |
submitTaskWithDuration(java.lang.Runnable task,
long duration)
Runs a task, cancelling it after the specified duration has passed from the time it started running.
|
<T> java.util.concurrent.Future<T> |
submitTaskWithDuration(java.lang.Runnable task,
T result,
long duration)
Runs a task, cancelling it after the specified duration has passed from the time it started running.
|
<T> java.util.concurrent.Future<T> |
submitTaskWithDurationAndEndTime(java.util.concurrent.Callable<T> task,
long duration,
long endTime)
Runs a task, cancelling it after the specified duration has passed from the time it started running, or if it hasn't finished by the given time.
|
java.util.concurrent.Future<java.lang.Boolean> |
submitTaskWithDurationAndEndTime(java.lang.Runnable task,
long duration,
long endTime)
Runs a task, cancelling it after the specified duration has passed from the time it started running, or if it hasn't finished by the given time.
|
<T> java.util.concurrent.Future<T> |
submitTaskWithDurationAndEndTime(java.lang.Runnable task,
T result,
long duration,
long endTime)
Runs a task, cancelling it after the specified duration has passed from the time it started running, or if it hasn't finished by the given time.
|
<T> java.util.concurrent.Future<T> |
submitTaskWithEndTime(java.util.concurrent.Callable<T> task,
long endTime)
Runs a task, cancelling it if it hasn't finished by the given time
|
java.util.concurrent.Future<java.lang.Boolean> |
submitTaskWithEndTime(java.lang.Runnable task,
long endTime)
Runs a task, cancelling it if it hasn't finished by the given time
|
<T> java.util.concurrent.Future<T> |
submitTaskWithEndTime(java.lang.Runnable task,
T result,
long endTime)
Runs a task, cancelling it if it hasn't finished by the given time
|
<T> java.util.concurrent.Future<T> |
submitUntimedTask(java.util.concurrent.Callable<T> callable)
Submits the given task but doesn't time it's execution.
|
java.util.concurrent.Future<?> |
submitUntimedTask(java.lang.Runnable runnable)
Submits the given task but doesn't time it's execution.
|
java.lang.String |
toString() |
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, terminatedpublic long getDefaultRunDuration()
public void setDefaultRunDuration(long duration)
duration - The default run duration, in milliseconds, that will be set for tasks with no duration specified. Negative values indicate infinite timepublic void shutdown()
shutdown in interface java.util.concurrent.ExecutorServiceshutdown in class java.util.concurrent.ThreadPoolExecutor@NotNull public java.util.List<java.lang.Runnable> shutdownNow()
shutdownNow in interface java.util.concurrent.ExecutorServiceshutdownNow in class java.util.concurrent.ThreadPoolExecutor@NotNull protected <T> java.util.concurrent.RunnableFuture<T> newTaskFor(java.lang.Runnable runnable, T result)
newTaskFor in class java.util.concurrent.AbstractExecutorService@NotNull protected <T> java.util.concurrent.RunnableFuture<T> newTaskFor(java.util.concurrent.Callable<T> callable)
newTaskFor in class java.util.concurrent.AbstractExecutorService@NotNull public <T> java.util.concurrent.Future<T> submitUntimedTask(@NotNull java.util.concurrent.Callable<T> callable)
T - The type of the returned datacallable - The task to runFuture used for getting the data and status updates@NotNull public java.util.concurrent.Future<?> submitUntimedTask(@NotNull java.lang.Runnable runnable)
runnable - The task to runFuture used for status updates@NotNull public <T> java.util.concurrent.Future<T> submitTaskWithDuration(@NotNull java.util.concurrent.Callable<T> task, long duration)
T - The type of data to returntask - The task to runduration - The maximum duration for which the task should run, in milliseconds (from the time it actually starts)Future that can be used to get the result upon completion@NotNull public java.util.concurrent.Future<java.lang.Boolean> submitTaskWithDuration(@NotNull java.lang.Runnable task, long duration)
task - The task to runduration - The maximum duration for which the task should run, in milliseconds (from the time it actually starts)Future that can be used to get the result upon completion@NotNull public <T> java.util.concurrent.Future<T> submitTaskWithDuration(@NotNull java.lang.Runnable task, T result, long duration)
T - The type of data to returntask - The task to runresult - The value to return when the task finishesduration - The maximum duration for which the task should run, in milliseconds (from the time it actually starts)Future that can be used to get the result upon completion@NotNull public <T> java.util.concurrent.Future<T> submitTaskWithEndTime(@NotNull java.util.concurrent.Callable<T> task, long endTime)
T - The type of data to returntask - The task to runendTime - The time at which the task should end if it hasn't finished yetFuture that can be used to get the result upon completion@NotNull public java.util.concurrent.Future<java.lang.Boolean> submitTaskWithEndTime(@NotNull java.lang.Runnable task, long endTime)
task - The task to runendTime - The time at which the task should end if it hasn't finished yetFuture that can be used to get the result upon completion@NotNull public <T> java.util.concurrent.Future<T> submitTaskWithEndTime(@NotNull java.lang.Runnable task, T result, long endTime)
T - The type of data to returntask - The task to runresult - The value to return when the task finishesendTime - The time at which the task should end if it hasn't finished yetFuture that can be used to get the result upon completion@NotNull public <T> java.util.concurrent.Future<T> submitTaskWithDurationAndEndTime(@NotNull java.util.concurrent.Callable<T> task, long duration, long endTime)
T - The type of data to returntask - The task to runduration - The maximum duration for which the task should run, in milliseconds (from the time it actually starts)endTime - The time at which the task should end if it hasn't finished yetFuture that can be used to get the result upon completion@NotNull public java.util.concurrent.Future<java.lang.Boolean> submitTaskWithDurationAndEndTime(@NotNull java.lang.Runnable task, long duration, long endTime)
task - The task to runduration - The maximum duration for which the task should run, in milliseconds (from the time it actually starts)endTime - The time at which the task should end if it hasn't finished yetFuture that can be used to get the result upon completion@NotNull public <T> java.util.concurrent.Future<T> submitTaskWithDurationAndEndTime(@NotNull java.lang.Runnable task, T result, long duration, long endTime)
T - The type of data to returntask - The task to runresult - The value to return when the task finishesduration - The maximum duration for which the task should run, in milliseconds (from the time it actually starts)endTime - The time at which the task should end if it hasn't finished yetFuture that can be used to get the result upon completion@NotNull public java.lang.String toString()
toString in class java.util.concurrent.ThreadPoolExecutor