Class DiscardWithCancelPolicy
Object
com.liferay.portal.kernel.concurrent.DiscardWithCancelPolicy
- All Implemented Interfaces:
RejectedExecutionHandler
Handles rejected tasks by canceling them immediately.
Use this policy for efficiently discarding rejected tasks. Unlike CallerRunsPolicy
, this policy maintains the order of tasks in the task
queue. Unlike DiscardOldestPolicy
and DiscardPolicy
, which
ultimately call Future.get()
, threads do not block waiting for a
timeout.
- Author:
- Shuyang Zhou
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
rejectedExecution
(Runnable runnable, ThreadPoolExecutor threadPoolExecutor) Rejects execution of theRunnable
task by canceling it immediately.
-
Constructor Details
-
DiscardWithCancelPolicy
public DiscardWithCancelPolicy()
-
-
Method Details
-
rejectedExecution
Rejects execution of theRunnable
task by canceling it immediately.Important: The task can only be canceled if it is a subtype of
Future
.- Specified by:
rejectedExecution
in interfaceRejectedExecutionHandler
- Parameters:
runnable
- the taskthreadPoolExecutor
- the executor- See Also:
-