com.liferay.portal.kernel.concurrent
Class DiscardWithCancelPolicy
java.lang.Object
com.liferay.portal.kernel.concurrent.DiscardWithCancelPolicy
- All Implemented Interfaces:
- RejectedExecutionHandler
public class DiscardWithCancelPolicy
- extends Object
- implements 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.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DiscardWithCancelPolicy
public DiscardWithCancelPolicy()
rejectedExecution
public void rejectedExecution(Runnable runnable,
ThreadPoolExecutor threadPoolExecutor)
- Rejects execution of the
Runnable
task by canceling it
immediately.
Important: The task can only be canceled if it is a subtype of Future
.
- Specified by:
rejectedExecution
in interface RejectedExecutionHandler
- Parameters:
runnable
- the taskthreadPoolExecutor
- the executor- See Also:
ThreadPoolExecutor.RejectedExecutionHandler