public class PriorityThreadPoolExecutor extends java.lang.Object implements PriorityExecutor
Added tasks of the same priority are run in order.
CANT_REMOVE, DIRECT_EXECUTOR, NO_ID| Constructor and Description |
|---|
PriorityThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit)
Constructor.
|
PriorityThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
Constructor.
|
PriorityThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.ThreadFactory threadFactory)
Constructor.
|
PriorityThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.ThreadFactory threadFactory,
java.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
long |
execute(Priority priority,
java.lang.Object mark,
java.lang.Runnable task)
Execute a task with the given priority.
|
long |
executeWithLifeCycle(Priority priority,
TaskLifeCycleListener mark,
java.lang.Runnable task)
Execute a task with the given priority.
|
int |
removeTasksWithMark(java.lang.Object mark)
Remove all tasks which where started with the given mark.
|
boolean |
removeTaskWithId(long id)
Remove the task with the given id.
|
public PriorityThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
@NotNull
java.util.concurrent.TimeUnit unit)
corePoolSize - core pool sizemaximumPoolSize - maximum pool sizekeepAliveTime - keep alive timeunit - keep alive time unitThreadPoolExecutor.ThreadPoolExecutor(int, int, long, java.util.concurrent.TimeUnit, java.util.concurrent.BlockingQueue)public PriorityThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
@NotNull
java.util.concurrent.TimeUnit unit,
@NotNull
java.util.concurrent.ThreadFactory threadFactory)
corePoolSize - core pool sizemaximumPoolSize - maximum pool sizekeepAliveTime - keep alive timeunit - keep alive time unitthreadFactory - thread creation factoryThreadPoolExecutor.ThreadPoolExecutor(int, int, long, java.util.concurrent.TimeUnit, java.util.concurrent.BlockingQueue, java.util.concurrent.ThreadFactory)public PriorityThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
@NotNull
java.util.concurrent.TimeUnit unit,
@NotNull
java.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
corePoolSize - core pool sizemaximumPoolSize - maximum pool sizekeepAliveTime - keep alive timeunit - keep alive time unitrejectedExecutionHandler - rejected execution handlerThreadPoolExecutor.ThreadPoolExecutor(int, int, long, java.util.concurrent.TimeUnit, java.util.concurrent.BlockingQueue, java.util.concurrent.ThreadFactory, java.util.concurrent.RejectedExecutionHandler)public PriorityThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
@NotNull
java.util.concurrent.TimeUnit unit,
@NotNull
java.util.concurrent.ThreadFactory threadFactory,
@NotNull
java.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
corePoolSize - core pool sizemaximumPoolSize - maximum pool sizekeepAliveTime - keep alive timeunit - keep alive time unitthreadFactory - thread creation factoryrejectedExecutionHandler - rejected execution handlerThreadPoolExecutor.ThreadPoolExecutor(int, int, long, java.util.concurrent.TimeUnit, java.util.concurrent.BlockingQueue, java.util.concurrent.ThreadFactory, java.util.concurrent.RejectedExecutionHandler)public long execute(@NotNull Priority priority, @Nullable java.lang.Object mark, @NotNull java.lang.Runnable task)
execute in interface PriorityExecutorpriority - priority of taskmark - mark which allows access to objects in queue.
Not all implementation need to take care of this.task - task to runremoveTasksWithMark(Object)public long executeWithLifeCycle(@NotNull Priority priority, @NotNull TaskLifeCycleListener mark, @NotNull java.lang.Runnable task)
executeWithLifeCycle in interface PriorityExecutorpriority - priority of taskmark - mark which allows access to objects in queue, and also gets informed
when the task is enqueued, started and finished.
Not all implementation need to take care of this.task - task to runPriorityExecutor.NO_ID
if access is no longer possiblepublic int removeTasksWithMark(@NotNull java.lang.Object mark)
removeTasksWithMark in interface PriorityExecutormark - mark to check forPriorityExecutor.CANT_REMOVE
if the executor does not allow removingpublic boolean removeTaskWithId(long id)
removeTaskWithId in interface PriorityExecutorid - idtrue if a rask with the given id was found and removedfalse: if none was found